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

A forum for questions or concerns related to the PDF-XChange Core API SDK

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Sean - Tracker, Chris - Tracker Supp, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
whoit
User
Posts: 271
Joined: Tue Jul 07, 2015 3:30 pm

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

Post by whoit » Tue Mar 08, 2016 7:10 pm

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

User avatar
Sasha - Tracker Dev Team
User
Posts: 4532
Joined: Fri Nov 21, 2014 8:27 am
Contact:

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

Post by Sasha - Tracker Dev Team » Wed Mar 09, 2016 12:51 pm

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
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

whoit
User
Posts: 271
Joined: Tue Jul 07, 2015 3:30 pm

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

Post by whoit » Wed Mar 09, 2016 2:13 pm

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.
Attachments
sample.pdf
Sample - open, click the button on the page. Select a PDF to add it to the button as an icon. In need to do this in code.
(102.98 KiB) Downloaded 81 times
pdf template option.pdf
Graphic explanation.
(64.86 KiB) Downloaded 84 times

User avatar
Sasha - Tracker Dev Team
User
Posts: 4532
Joined: Fri Nov 21, 2014 8:27 am
Contact:

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

Post by Sasha - Tracker Dev Team » Wed Mar 09, 2016 4:03 pm

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
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

whoit
User
Posts: 271
Joined: Tue Jul 07, 2015 3:30 pm

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

Post by whoit » Wed Mar 09, 2016 5:51 pm

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?

User avatar
Sasha - Tracker Dev Team
User
Posts: 4532
Joined: Fri Nov 21, 2014 8:27 am
Contact:

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

Post by Sasha - Tracker Dev Team » Wed Mar 09, 2016 7:01 pm

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
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

whoit
User
Posts: 271
Joined: Tue Jul 07, 2015 3:30 pm

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

Post by whoit » Wed Mar 09, 2016 7:54 pm

Great - we'll give it a try.

Thanks again!

mmasood
User
Posts: 99
Joined: Fri Sep 18, 2015 9:49 pm

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

Post by mmasood » Wed Mar 09, 2016 9:31 pm

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

User avatar
Tracker Supp-Stefan
Site Admin
Posts: 13663
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

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

Post by Tracker Supp-Stefan » Thu Mar 10, 2016 11:43 am

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

User avatar
Sasha - Tracker Dev Team
User
Posts: 4532
Joined: Fri Nov 21, 2014 8:27 am
Contact:

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

Post by Sasha - Tracker Dev Team » Fri Mar 11, 2016 3:19 pm

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
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

mmasood
User
Posts: 99
Joined: Fri Sep 18, 2015 9:49 pm

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

Post by mmasood » Thu Mar 24, 2016 6:56 pm

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

User avatar
Sasha - Tracker Dev Team
User
Posts: 4532
Joined: Fri Nov 21, 2014 8:27 am
Contact:

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

Post by Sasha - Tracker Dev Team » Fri Mar 25, 2016 7:40 am

Hello mmasood,

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

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

mmasood
User
Posts: 99
Joined: Fri Sep 18, 2015 9:49 pm

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

Post by mmasood » Fri Mar 25, 2016 6:03 pm

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
Attachments
clStampingPDF.rar
(851.23 KiB) Downloaded 75 times

User avatar
Sasha - Tracker Dev Team
User
Posts: 4532
Joined: Fri Nov 21, 2014 8:27 am
Contact:

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

Post by Sasha - Tracker Dev Team » Mon Mar 28, 2016 7:56 am

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
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

mmasood
User
Posts: 99
Joined: Fri Sep 18, 2015 9:49 pm

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

Post by mmasood » Mon Mar 28, 2016 7:23 pm

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

User avatar
Sasha - Tracker Dev Team
User
Posts: 4532
Joined: Fri Nov 21, 2014 8:27 am
Contact:

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

Post by Sasha - Tracker Dev Team » Tue Mar 29, 2016 2:34 pm

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
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

Post Reply