I have 2 PDFs:
DocA = 612 x 792 (an 8/12 x 11 portrait), DocA is always this size and orientation, also i alwys clip out the exact same area.
Psuedo-code:
ImportedPageContents contents = null;
contents = new ceTe.DynamicPDF.Merger.ImportedPageContents("DocA",1);
contents.ClipLeft = 190;
contents.ClipRight = 375;
contents.ClipTop = 581;
contents.ClipBottom = 164;
DocB = 595 x 842 (an A4), DocB has a "variable size", could be portrait or landscape, could be A4, A2, or whatever
I need to extract out thd area from DocA (always the same area) and place it on DocB. When I do this, what would be a generic algorithm to calculate the offset given that DocB (the one I want to place the contents on) could be any size/orientation?
ImportedPageData from different size PDFs
Re: ImportedPageData from different size PDFs
Support · Aug 6, 2008Hello,
Are you trying to add a PDF page to a different PDF page with different size? If so you can use the following sample code.
//This PDF has pages with different sizes and orientation
MergeDocument doc = new MergeDocument(@"C:\Temp\DifferentSizePages.pdf");
//Take an imported area
ImportedPageArea pageArea;
for(int i=0; i<doc.Pages.Count; i++)
{
//Get the page area from a different PDF with different size
pageArea = new ImportedPageArea(@"C:\Temp\fw9AcroForm_03.pdf", i + 1, 0, 0);
set the imported area height and width to the height and width of the page to which we are going to add.
pageArea.Height = doc.Pages[i].Dimensions.Body.Height;
pageArea.Width = doc.Pages[i].Dimensions.Body.Width;
Add the page area to the destination page
doc.Pages[i].Elements.Add(pageArea);
}
doc.DrawToWeb();
Thanks,
ceTe Software Support Team.
Re: ImportedPageData from different size PDFs
Forum member · Aug 6, 2008I am just taking a section (about a 50 x 50 area) from an 8 1/2 x 11 (612 x 792) PDF page, i.e. putting that into an ImportedPageContents object. I then need to take the ImportedPageContents object and place that at a specific x and y location on a completely seperate A4 (595 x 842) PDF page.
Re: ImportedPageData from different size PDFs
Support · Aug 6, 2008Hello,
You can use the ImportedPageArea class and pass the ImportedPageContents to the ImportedPageArea constructor. Also specify the X an Y coordinate in the constructor and it will add the contents at those coordinates.
Thanks,
ceTe Software Support Team
Re: ImportedPageData from different size PDFs
Forum member · Aug 6, 2008Thanks, it helps if I use the right object. I was trying to use the ImportedPageData object and figure out the offsets. Thanks again.