0

このコードを作成して、既存のpdfの2ページ目にpdfをマージ挿入しました。できます。しかし、問題は、挿入されたpdfが横向きモードであることです。つまり、サイズが異なりますが、実際には縦向きモードですが、挿入後は横向きになります。理由はわかりません。それを設定する方法は?

private static string AppendToDocument(string FirstSource, string SecondSource)
{
    String first_source =  FirstSource; 
    String second_source = SecondSource; 
    String pathout = "D:/Shared Data/test.pdf";
    //create a document object
    //var doc = new Document(PageSize.A4);
    //create PdfReader objects to read pages from the source files
    PdfReader reader = new PdfReader(first_source);
    PdfReader reader1 = new PdfReader(second_source);
    //create PdfStamper object to write to the pages read from readers 
    PdfStamper stamper = new PdfStamper(reader1, new FileStream(pathout, FileMode.Create));
    //get one page from htmlpdf.pdf
    PdfImportedPage page = stamper.GetImportedPage(reader, 1);
    //the page gotten from htmlpdf.pdf will be inserted at the second page in the first source doc
    stamper.InsertPage(2, reader1.GetPageSize(1));
    //insert the page
    PdfContentByte pb = stamper.GetUnderContent(2);
    pb.AddTemplate(page, 0, 0);
    //close the stamper
    stamper.Close();

    return pathout;
}

FirstSourceおよびSecondSourceは物理パスです。

4

0 に答える 0