I have pdf files exported as legal format and want to convert them to letter format (basically shrink them), each file may have 1 to 3 pages, below is the code I tried but I have these problems:
the page size is reduced which is good, but I can't use the margin properties to put the page at the correct borders of the container (the page I kind of shrinked but drawn somewhere at the bottom of the resulted pdf file)
I couldn't increment the number of pages so the code draws both pages, one on top of the other.
Here's the code
PdfImportedPage page;
PdfReader reader = new PdfReader(@"C:\pdf\legalFormat.pdf");
Document doc = new Document(PageSize.A4, 0, 0, 0, 0);
PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(@"C:\pdf\letterFormat.PDF", FileMode.Create));
doc.Open();
PdfContentByte cb = writer.DirectContent;
for (int i = 1 ; i < reader.NumberOfPages + 1; i++){
page = writer.GetImportedPage(reader, i); // i is the number of page
float Scale = 0.67f;
cb.AddTemplate(page, Scale, 0, 0, Scale, 0, 0);
}
doc.Close();