I have a PDF Document (approx 20 pages) in landscape orientation.  I want to import a one-page PDF Document, also in landscape orientation, and place that page on top of one of the existing pages in the 20-page PDF document.

 

My problem is that when I import the one-page PDF document it “appears” in Portrait orientation (i.e. the top left corner of the one-page PDF is placed at the bottom-left corner of the 20-page PDF).

 

I’ve check the /Rotate value for the 1-page PDF, and it equals 90.  But the page is still displayed in Portrait orientation.

 

Here’s the code:

 

PdfReader reader = new PdfReader("20-page.pdf");

PdfStamper stamp = new PdfStamper(reader, new FileOutputStream("Renamed-20-page.pdf"));

AcroFields formFields = stamp.getAcroFields();

.

//Fill in various Fields

.

PdfReader theAdvisorReader = new PdfReader("1-page.pdf");

.

populateAdvisorPage(stamp, theAdvisorReader);

.

.

.

private void populateAdvisorPage(PdfStamper stamp, PdfReader reader) throws Exception

{

          //Read in 1-page PDF File

          PdfImportedPage theAdvisorPage = stamp.getImportedPage(reader, 1);

 

          //Get Over Content for Page #15 in 20-page.PDF

          PdfContentByte pdfContentByte = stamp.getOverContent(15);

 

          //Add 1-page PDF to 20-page PDF

          pdfContentByte.addTemplate(theAdvisorPage, 0, 0);

}

 

Any help is much appreciated.

 

John

 

Reply via email to