Page 1 of 1

Embed a PDF page into a PDF form (field) ?

Posted: Tue Mar 08, 2016 7:10 pm
by whoit
Is is possible, using any of the Tracker libraries, to embed a PDF page into a field in a different PDF document (form) ?

For example, I have a PDF Form that includes a few text fields,
and I'd like to use another field to contain a pdf page from another document
(kind of like a screenshot - however I do NOT want the image to be bitmap)

Thanks,
Wayne

Re: Embed a PDF page into a PDF form (field) ?

Posted: Wed Mar 09, 2016 12:51 pm
by Sasha - Tracker Dev Team
Hello whoit,

We did not quite understand what do you want. Can you provide more detailed description and a picture of what you want?

Cheers,
Alex

Re: Embed a PDF page into a PDF form (field) ?

Posted: Wed Mar 09, 2016 2:13 pm
by whoit
I need to be able to open a PDF document (1), and also open a PDF Form (2).
Then I need to take a page from the PDF Document (1) and insert it into a Button Field (as an Icon)
within the PDF Form (2).

I have provided a sample graphic and form.

Re: Embed a PDF page into a PDF form (field) ?

Posted: Wed Mar 09, 2016 4:03 pm
by Sasha - Tracker Dev Team
Hello whoit,

Now that's what i call a detailed sample :D
What you want is doable, though should be available from the next release when the work with forms should be updated.
The steps should be the following:
1) http://sdkhelp.tracker-software.com/vie ... ieldByName
2) http://sdkhelp.tracker-software.com/vie ... eld_Widget
3) http://sdkhelp.tracker-software.com/vie ... Annotation
4) http://sdkhelp.tracker-software.com/vie ... ation_Data
of this type
http://sdkhelp.tracker-software.com/vie ... ata_Widget
And the final step will be this:
http://sdkhelp.tracker-software.com/vie ... et_SetIcon

HTH,
Alex

Re: Embed a PDF page into a PDF form (field) ?

Posted: Wed Mar 09, 2016 5:51 pm
by whoit
Alex - Glad you liked it! (don't get used to it! :wink: )

Ok so now I have some follow-up questions:

(You didn't think I was done, did you?? :) )

Is there any way to do this in the current version of the libs?
(Perhaps a different kind of form field?
or adding the image via disk file instead of opening into Tracker libs first?)

So of course the next question is: when the release supporting this be available?

Re: Embed a PDF page into a PDF form (field) ?

Posted: Wed Mar 09, 2016 7:01 pm
by Sasha - Tracker Dev Team
Well, you can try doing that by using the code links that I've post (I think that code is available right now). If something does not work - the release will be at a week or so - Stefan wrote you in another thread (we update all of our products at once - they have the same Core).

Cheers,
Alex

Re: Embed a PDF page into a PDF form (field) ?

Posted: Wed Mar 09, 2016 7:54 pm
by whoit
Great - we'll give it a try.

Thanks again!

Re: Embed a PDF page into a PDF form (field) ?

Posted: Wed Mar 09, 2016 9:31 pm
by mmasood
Hi Alex,

I am following the steps that you mentioned the post above but need some help completing the last step.

Following is the code that I have:

Code: Select all

PDFXEdit.IPXC_FormField field = pdfControlInvisible.Doc.CoreDoc.AcroForm.GetFieldByName(fld.FieldName);

PDFXEdit.IPXC_Annotation annotation = field.get_Widget(0);

IPXC_AnnotData_Widget annotdata = (IPXC_AnnotData_Widget)annotation.Data;

// open a pdf that is to be set on the first document
pdfEditor.OpenDocFromPath(@"SP.pdf");
                        
annotdata.SetIcon(PXC_AnnotAppType.AAT_Normal, pdfEditor.Doc.CoreDoc.GetXForm([color=#FF0000]???[/color]), false);
Questions:

1. Is this the approach that you are talking about?
2. What should I pass to the GetXForm function?

Regards,
M

Re: Embed a PDF page into a PDF form (field) ?

Posted: Thu Mar 10, 2016 11:43 am
by Tracker Supp-Stefan
Hello M Masood,

Sasha mentioned above that this process will work from next build onwards, but he is currently investigating if it can be achieved with the current one as well. He will post in the topic later if he has further advise for how to do it with the available tools.

Cheers,
Stefan

Re: Embed a PDF page into a PDF form (field) ?

Posted: Fri Mar 11, 2016 3:19 pm
by Sasha - Tracker Dev Team
Hi guys,

So we've tried with different methods and it appears that not enough functionality was available through the SDK interfaces. We've added the CreateXFormFromPage method to the IPXC_Document interface that will be available from the next release (317) that should be out in a week or so if everything goes as planned.
Thus using this method will allow to convert given page in the source document into an XForm in the destination document. And then using the SetIcon method the widget's icon will be modified.

HTH,
Alex

Re: Embed a PDF page into a PDF form (field) ?

Posted: Thu Mar 24, 2016 6:56 pm
by mmasood
Hi Alex,

I have downloaded the latest build and updated the code to below:

Code: Select all

PDFXEdit.IPXC_FormField field = pdfControl1.Doc.CoreDoc.AcroForm.GetFieldByName("button");

PDFXEdit.IPXC_Annotation annotation = field.get_Widget(0);

IPXC_AnnotData_Widget annotdata = (IPXC_AnnotData_Widget)annotation.Data;

// open a pdf that is to be set on the first document                        
pdfControl2.OpenDocFromPath(@"SP.pdf");

IPXC_Page page1 = pdfControl2.Doc.CoreDoc.Pages[0];

IPXC_XForm xform = pdfControl2.Doc.CoreDoc.CreateXFormFromPage(page1);

annotdata.SetIcon(PXC_AnnotAppType.AAT_Normal, xform, false);

I am getting the exception "Value does not fall within the expected range." on the last line.

How do I fix this issue?

Regards,
M

Re: Embed a PDF page into a PDF form (field) ?

Posted: Fri Mar 25, 2016 7:40 am
by Sasha - Tracker Dev Team
Hello mmasood,

This code works for me with your sample. Here's my code:
https://gist.github.com/Polaringu/f661a5af12c8fbf7e7fd

Cheers,
Alex

Re: Embed a PDF page into a PDF form (field) ?

Posted: Fri Mar 25, 2016 6:03 pm
by mmasood
Hi Alex,

I am trying the code that you provided. It does not give me an exception but does not do anything either. There is no icon added to the button after the process is done. I have attached a sample project with the post. Is there something missing in the code that is causing the issue?

Regards,
M

Re: Embed a PDF page into a PDF form (field) ?

Posted: Mon Mar 28, 2016 7:56 am
by Sasha - Tracker Dev Team
Hello mmasood,

The code worked correctly, but you'll need to change the widget's layout type (set it to show the icon):
https://gist.github.com/Polaringu/f661a ... con-cs-L13

Cheers,
Alex

Re: Embed a PDF page into a PDF form (field) ?

Posted: Mon Mar 28, 2016 7:23 pm
by mmasood
Hi Alex,

I am trying to run the updated code (with the line that you added) and it is doing nothing. Just creates a PDF file with nothing set as the button icon. I also tried it with a new PDF Form but still the same thing.

Regards,
M

Re: Embed a PDF page into a PDF form (field) ?

Posted: Tue Mar 29, 2016 2:34 pm
by Sasha - Tracker Dev Team
Hello mmasood,

The strange thing is that this is working correctly when you have one Editor ActiveX Control with multiple documents opened and also works well on the Core API level - when you open two IPXC_Document.
But when you have two different Controls then this issue occurs - that's what I investigated. Right now I can't say why does this behaves like this, though I've managed to find a strange solution described here:
https://gist.github.com/Polaringu/36072 ... t-cs-L2-L4

HTH,
Alex