Can the Core API perform these functions?
Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, 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.
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.
Can the Core API perform these functions?
Hi,
I am evaluating the Core API and here is a list of things that I need to achieve using only the Core API:
1. Open/Edit PDF document of any version (e.g. 1.4,1.5,1.6,1.7)
2. Manipulate PDF Forms and get Field positions of each of the fields present in a PDF form.
3. Draw fields/text on any custom location in the PDF document.
4. Merge multiple PDF documents.
5. Add watermarks.
6. Handle different page sizes of the PDF document.
7. Handle page angles
8. Add margins to a page and redraw a page
9. Layer support
So my question is
Can I do all of the above with the Core API?
Thanks,
M
I am evaluating the Core API and here is a list of things that I need to achieve using only the Core API:
1. Open/Edit PDF document of any version (e.g. 1.4,1.5,1.6,1.7)
2. Manipulate PDF Forms and get Field positions of each of the fields present in a PDF form.
3. Draw fields/text on any custom location in the PDF document.
4. Merge multiple PDF documents.
5. Add watermarks.
6. Handle different page sizes of the PDF document.
7. Handle page angles
8. Add margins to a page and redraw a page
9. Layer support
So my question is
Can I do all of the above with the Core API?
Thanks,
M
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Can the Core API perform these functions?
Hello mmasood,
You can do these things using the Core API. Though if you want interactivity i.e. control on the form that would display your document and allow interactive features you should use the Editor SDK. Also, using the Editor SDK will allow to simplify the usage of our core functionality via using the operations. For example, merging the documents will require a big piece of code to be written in the Core API and the Editor SDK will allow to do that just by using one operation call.
HTH,
Alex
You can do these things using the Core API. Though if you want interactivity i.e. control on the form that would display your document and allow interactive features you should use the Editor SDK. Also, using the Editor SDK will allow to simplify the usage of our core functionality via using the operations. For example, merging the documents will require a big piece of code to be written in the Core API and the Editor SDK will allow to do that just by using one operation call.
HTH,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Can the Core API perform these functions?
Hi Alex,
I am using Editor SDK per your suggestion. I am using C# as the development language. I have been able to open a PDF Form and enter my own text in the fields. The next step that I need your help with are:
1. How can I access the coordinates of different fields on the PDF Form?
2. How can I take a PDF page and embed it on specific coordinates on another PDF page?
Can you provide me some sample code using the Editor SDK to perform these operations in C# or VB.NET?
Thanks.
M
I am using Editor SDK per your suggestion. I am using C# as the development language. I have been able to open a PDF Form and enter my own text in the fields. The next step that I need your help with are:
1. How can I access the coordinates of different fields on the PDF Form?
2. How can I take a PDF page and embed it on specific coordinates on another PDF page?
Can you provide me some sample code using the Editor SDK to perform these operations in C# or VB.NET?
Thanks.
M
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Can the Core API perform these functions?
Hello mmasood,
1. You can get a Widget from the Field using this property https://sdkhelp.pdf-xchange.com/vie ... eld_Widget. And then you can get annotation https://sdkhelp.pdf-xchange.com/vie ... ation_Rect property to get it's coordinates on a page.
2. We can do that, but the problem is that we only can flatten or exclude fields when doing the embedding process. Please add more details to what you want and I'll write you a sample.
HTH,
Alex
1. You can get a Widget from the Field using this property https://sdkhelp.pdf-xchange.com/vie ... eld_Widget. And then you can get annotation https://sdkhelp.pdf-xchange.com/vie ... ation_Rect property to get it's coordinates on a page.
2. We can do that, but the problem is that we only can flatten or exclude fields when doing the embedding process. Please add more details to what you want and I'll write you a sample.
HTH,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Can the Core API perform these functions?
Hi Alex,
Thanks for the information, I am able to get the coordinates from the Form controls.
Regarding point 2, i think that flattening the fields will work in my case. However, if it does not work, can I embed the page from the second pdf and then draw/create the controls on the desired coordinates?
Can you provide me with the code for flattening the controls and embedding the second page at the specified coordinates in C# or VB.NET?
Regards,
M
Thanks for the information, I am able to get the coordinates from the Form controls.
Regarding point 2, i think that flattening the fields will work in my case. However, if it does not work, can I embed the page from the second pdf and then draw/create the controls on the desired coordinates?
Can you provide me with the code for flattening the controls and embedding the second page at the specified coordinates in C# or VB.NET?
Regards,
M
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Can the Core API perform these functions?
Hello mmasood,
Here's the sample on how to do that. Note that there are few issues with this functionality and it will be available in one of the nearest future builds.
HTH,
Alex
Here's the sample on how to do that. Note that there are few issues with this functionality and it will be available in one of the nearest future builds.
Code: Select all
private PDFXEdit.PXC_Matrix RectToRectMatrix(PDFXEdit.PXC_Rect from, PDFXEdit.PXC_Rect to)
{
PDFXEdit.PXC_Matrix m;
if ((to.right == to.left) || (to.top == to.bottom) ||
(from.left == from.right) || (from.top == from.bottom))
{
m.a = m.d = 1.0;
}
else
{
m.a = ((to.right - to.left) / (from.right - from.left));
m.d = ((to.top - to.bottom) / (from.top - from.bottom));
}
m.b = 0;
m.c = 0;
m.e = (to.left - from.left * m.a);
m.f = (to.bottom - from.bottom * m.d);
return m;
}
private PDFXEdit.PXC_Matrix Multiply(PDFXEdit.PXC_Matrix m1, PDFXEdit.PXC_Matrix m2)
{
double t0 = (double)(m1.a * m2.a + m1.b * m2.c);
double t2 = (double)(m1.c * m2.a + m1.d * m2.c);
double t4 = (double)(m1.e * m2.a + m1.f * m2.c + m2.e);
m1.b = (double)(m1.a * m2.b + m1.b * m2.d);
m1.d = (double)(m1.c * m2.b + m1.d * m2.d);
m1.f = (double)(m1.e * m2.b + m1.f * m2.d + m2.f);
m1.a = t0;
m1.c = t2;
m1.e = t4;
return m1;
}
private double Determinant(PDFXEdit.PXC_Matrix m)
{
double dd = (m.a * m.d - m.b * m.c);
return ((dd == 0) ? 1.0 : (1.0 / dd));
}
private PDFXEdit.PXC_Matrix Invert(PDFXEdit.PXC_Matrix dest)
{
double det = Determinant(dest);
double t0 = dest.d * det;
dest.d = dest.a * det;
dest.b = -dest.b * det;
dest.c = -dest.c * det;
double t4 = -dest.e * t0 - dest.f * dest.c;
dest.f = -dest.e * dest.b - dest.f * dest.d;
dest.a = t0;
dest.e = t4;
return dest;
}
void UpdateMinMax(double v, ref double vMin, ref double vMax)
{
if (vMin > v)
vMin = v;
if (vMax < v)
vMax = v;
}
private void Transform(PDFXEdit.PXC_Matrix m1, ref double x, ref double y)
{
double tx = x;
x = (tx * m1.a + y * m1.c + m1.e);
y = (tx * m1.b + y * m1.d + m1.f);
}
private void TransformRect(PDFXEdit.PXC_Matrix m1, ref PDFXEdit.PXC_Rect rcPageBox)
{
double x = rcPageBox.left;
double y = rcPageBox.bottom;
Transform(m1, ref x, ref y);
double x1 = x;
double x2 = x;
double y1 = y;
double y2 = y;
x = rcPageBox.left;
y = rcPageBox.top;
Transform(m1, ref x, ref y);
UpdateMinMax(x, ref x1, ref x2);
UpdateMinMax(y, ref y1, ref y2);
x = rcPageBox.right;
y = rcPageBox.top;
Transform(m1, ref x, ref y);
UpdateMinMax(x, ref x1, ref x2);
UpdateMinMax(y, ref y1, ref y2);
x = rcPageBox.right;
y = rcPageBox.bottom;
Transform(m1, ref x, ref y);
UpdateMinMax(x, ref x1, ref x2);
UpdateMinMax(y, ref y1, ref y2);
rcPageBox.left = x1;
rcPageBox.right = x2;
rcPageBox.bottom = y1;
rcPageBox.top = y2;
}
private void getFormFieldsToolStripMenuItem_Click(object sender, EventArgs e)
{
PDFXEdit.IPXC_Document SrcDoc = pxcInst.OpenDocumentFromFile("D:\\TestFile.pdf", null);
PDFXEdit.IPXC_Document DestDoc = pxcInst.OpenDocumentFromFile("D:\\TestFile1.pdf", null);
PDFXEdit.IPXC_PagesOverlayInfo poi = pxcInst.CreatePagesOverlayInfo();
//Getting source page
PDFXEdit.IPXC_Page srcPage = SrcDoc.Pages[0];
//Getting source page matrix
PDFXEdit.PXC_Matrix srcPageMatrix = srcPage.GetMatrix(PDFXEdit.PXC_BoxType.PBox_PageBox);
//Getting source page Page Box without rotation
PDFXEdit.PXC_Rect srcRect = srcPage.get_Box(PDFXEdit.PXC_BoxType.PBox_PageBox);
//Getting visual source Page Box by transforming it through matrix
TransformRect(srcPageMatrix, ref srcRect);
//Getting destination page
PDFXEdit.IPXC_Page destPage = DestDoc.Pages[0];
//Getting destination page matrix
PDFXEdit.PXC_Matrix destPageMatrix = destPage.GetMatrix(PDFXEdit.PXC_BoxType.PBox_PageBox);
//Getting destination page Page Box without rotation
PDFXEdit.PXC_Rect destRect = destPage.get_Box(PDFXEdit.PXC_BoxType.PBox_PageBox);
//Getting visual destination Page Box by transforming it through matrix
TransformRect(destPageMatrix, ref destRect);
//Forming resulting rectangle by indenting from the visual destination rectangle borders
destRect.bottom += 100;
destRect.top -= 100;
destRect.left += 100;
destRect.right -= 100;
//We'll insert the visual src page into visual dest page indented rectangle including page rotations and clipping
PDFXEdit.PXC_Matrix pageToRectMatrix = RectToRectMatrix(srcRect, destRect);
//For that we invert and multiply matrix
destPageMatrix = Invert(destPageMatrix);
pageToRectMatrix = Multiply(pageToRectMatrix, destPageMatrix);
//Inserting new data into the pages overlay info meaning we insert 0 source page into 0 destination page using the constructed matrix
poi.InsertNew2(0, 0, ref pageToRectMatrix);
//Applying overlays for the destination document
DestDoc.Pages.OverlayPages(SrcDoc, poi);
//Saving the document
DestDoc.WriteToFile("D:\\TestFile_res.pdf");
}
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 18
- Joined: Wed Feb 24, 2016 6:51 pm
Re: Can the Core API perform these functions?
Hi Alex,
I am trying to use the code you have provided in response to mmasood's last query. In a method getFormFieldsToolStripMenuItem_Click(object sender, EventArgs e) you have used pxcInst instance of some control. Kindly let me know which control is this? I am using PDF-XChange Editor SDK with c# as development language.
Regards,
Usman.
I am trying to use the code you have provided in response to mmasood's last query. In a method getFormFieldsToolStripMenuItem_Click(object sender, EventArgs e) you have used pxcInst instance of some control. Kindly let me know which control is this? I am using PDF-XChange Editor SDK with c# as development language.
Regards,
Usman.
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Can the Core API perform these functions?
Hello usmanakhtar,
It's the IPXC_Inst that you should have got when you initialize the Core API. I just had a global variable with is for easier usage. As you are using the Editor SDK so that you can look inside the FullDemo sample on how to get it. Also note, that this code won't work correctly right now - our inner methods will be updated for that use in the nearest future builds.
Cheers,
Alex
It's the IPXC_Inst that you should have got when you initialize the Core API. I just had a global variable with is for easier usage. As you are using the Editor SDK so that you can look inside the FullDemo sample on how to get it. Also note, that this code won't work correctly right now - our inner methods will be updated for that use in the nearest future builds.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 18
- Joined: Wed Feb 24, 2016 6:51 pm
Re: Can the Core API perform these functions?
Hi Alex,
Is it possible to convert the pages of one pdf document to images one by one and then put these image on the second pdf document at the specified coordinates.Can we convert page to verctor image. If possible then kindly provide me some code in C# or VB.NET?
Regards,
Usman Akhtar.
Is it possible to convert the pages of one pdf document to images one by one and then put these image on the second pdf document at the specified coordinates.Can we convert page to verctor image. If possible then kindly provide me some code in C# or VB.NET?
Regards,
Usman Akhtar.
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Can the Core API perform these functions?
Hello usmanakhtar,
Yes it's possible and will work as described as in the sample above - Please search the forums and help files before asking questions to avoid duplicate posts.
Cheers,
Alex
Yes it's possible and will work as described as in the sample above - Please search the forums and help files before asking questions to avoid duplicate posts.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 18
- Joined: Wed Feb 24, 2016 6:51 pm
Re: Can the Core API perform these functions?
Hi Alex,
I am trying to flatten the fields on a PDF Form using the "pdfEditor.Doc.CoreDoc.AcroForm.FlattenField" and "pdfEditor.Doc.CoreDoc.AcroForm.FlattenAllFields" methods but I am getting the same exception.
"The method or operation is not implemented."
Can you let me know how can I achieve the flattening of fields or a work around for this?
Regards,
Usman
I am trying to flatten the fields on a PDF Form using the "pdfEditor.Doc.CoreDoc.AcroForm.FlattenField" and "pdfEditor.Doc.CoreDoc.AcroForm.FlattenAllFields" methods but I am getting the same exception.
"The method or operation is not implemented."
Can you let me know how can I achieve the flattening of fields or a work around for this?
Regards,
Usman
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Can the Core API perform these functions?
Hello usmanakhtar,
That means that these methods are not implemented yet. We will try to implement them in the nearest future.
You can use the Editor SDK to do that by using flatten annotations operation:
https://sdkhelp.pdf-xchange.com/vie ... ts_flatten
Cheers,
Alex
That means that these methods are not implemented yet. We will try to implement them in the nearest future.
You can use the Editor SDK to do that by using flatten annotations operation:
https://sdkhelp.pdf-xchange.com/vie ... ts_flatten
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 18
- Joined: Wed Feb 24, 2016 6:51 pm
Re: Can the Core API perform these functions?
Hi,
Thanks Alex. Can you provide me with some code in c# for using "op.annots.flatten" to flatten the document.
Regards,
Usman Akhtar.
Thanks Alex. Can you provide me with some code in c# for using "op.annots.flatten" to flatten the document.
Regards,
Usman Akhtar.
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Can the Core API perform these functions?
I've updated the help files:
https://sdkhelp.pdf-xchange.com/vie ... ten#Sample
https://sdkhelp.pdf-xchange.com/vie ... ten#Sample
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ