Limits of import pdf page

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
dkaip
I live to help wx-kind
I live to help wx-kind
Posts: 189
Joined: Wed Jan 20, 2010 1:15 pm

Limits of import pdf page

Postby dkaip » Thu Jun 14, 2018 1:24 pm

Importing a page in pdf document and inserting a page how i can know the limits of import?
I am thinking that left and right are GetLeftMargin(); and GetTopMargin();
Is that right?
But what is bottom and right space? How i can find it?
Thank's
Jim

Code: Select all

afile.AddPage(-1,pageWidth,pageHight);
int tpl = afile.ImportPage(i);
double w=afile.GetPageWidth();
double h=afile.GetPageHeight();
afile.UseTemplate(tpl,0,0,w,h);

utelle
Moderator
Moderator
Posts: 823
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: Limits of import pdf page

Postby utelle » Thu Jun 14, 2018 8:30 pm

dkaip wrote:Importing a page in pdf document and inserting a page how i can know the limits of import?

You can't. That is, at least wxPdfDocument doesn't offer any methods for this.

dkaip wrote:I am thinking that left and right are GetLeftMargin(); and GetTopMargin();
Is that right?

No. GetLeftMargin, GetTopMargin, GetRightMargin return the margins set for the main document, not for the imported page.

dkaip wrote:But what is bottom and right space? How i can find it?

wxPdfDocument does not offer any methods to analyze the content of imported pages. That is, it is not possible to detect the margins used on the imported page.

Looking at your code sample it seems to be the right approach to use page width and height for the template. However, variable w will have the same value as pageWidth, and h the same value as pageHeight. This way, the imported page will be scaled to fit on the newly added page.

Regards,

Ulrich

dkaip
I live to help wx-kind
I live to help wx-kind
Posts: 189
Joined: Wed Jan 20, 2010 1:15 pm

Re: Limits of import pdf page

Postby dkaip » Thu Jun 14, 2018 9:04 pm

This means that inserting page has two different scales, scaleX and scale Y
Suppose we have ...

Page to be importing .. lx1,ly1
GetLeftMarging a1
GetRightMarging b1
GetTopMarging c1

pdf doc page ... lx2,ly2
GetLeftMarging a2
GetRightMarging b2
GetTopMarging c2

The area (lx1-a1-b1)X(ly1-c1-c1) must convert to area (lx2-a2-b2)X(ly2-c2-c2)
and scales must be
fx=(lx1-a1-b1)/lx2-a2-b2) and =(ly1-c1-c1)/(ly2-c2-c2)

Is that right?

utelle
Moderator
Moderator
Posts: 823
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: Limits of import pdf page

Postby utelle » Thu Jun 14, 2018 10:23 pm

dkaip wrote:This means that inserting page has two different scales, scaleX and scale Y
Suppose we have ...

Page to be importing .. lx1,ly1
GetLeftMarging a1
GetRightMarging b1
GetTopMarging c1

pdf doc page ... lx2,ly2
GetLeftMarging a2
GetRightMarging b2
GetTopMarging c2

The area (lx1-a1-b1)X(ly1-c1-c1) must convert to area (lx2-a2-b2)X(ly2-c2-c2)
and scales must be
fx=(lx1-a1-b1)/lx2-a2-b2) and =(ly1-c1-c1)/(ly2-c2-c2)

Is that right?

If the page size of the main PDF document and the page size of the imported page are different, then you would indeed get a slightly distorted version of the imported page in your main PDF document. That is, you should use GetTemplateBBox or GetTemplateSize to determine the dimensions of the imported page, so that you can either adjust the page size for the new page to be added or scale the imported page correctly.

The template sample coming with wxPdfDocument shows an example (inspect the code in samples/minimal/templates.cpp).

Regards,

Ulrich

dkaip
I live to help wx-kind
I live to help wx-kind
Posts: 189
Joined: Wed Jan 20, 2010 1:15 pm

Re: Limits of import pdf page

Postby dkaip » Fri Jun 15, 2018 4:22 am

Thank you very match for your answer. I will study template to understand the mechanism.
Jim.


Return to “wxCode”

Who is online

Users browsing this forum: No registered users and 0 guests