Hi,
We have a license for PDFXEditCore.x86.dll.
Would like to know whether this dll will support the flattening operation. If so, can you please send the usage of it. A sample code will help.
Thanks.
Flattening with PDFXEditCore.x86.dll
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.
Re: Flattening with PDFXEditCore.x86.dll
Is there any way we can programmatically achieve the UI functionality of Comments->flattening, with any API calls?
We have license for the PDFXEdit version of the dll. It is highly appreciated if you can tell a way to do this using the PDF Xchange editor API’s. The below code is written in Vb.net.
Dim filename As String = "C:\pdf-to-flatten.pdf"
Dim filename2 As String = "C:\flattened.pdf"
Dim m_CurDoc As PDFXCoreAPI.IPXC_Document
Dim pdfInst As PDFXCoreAPI.PXC_Inst
Dim acroForm As PDFXCoreAPI.IPXC_AcroForm
pdfInst = New PDFXCoreAPI.PXC_Inst()
pdfInst.Init("")
m_CurDoc = pdfInst.OpenDocumentFromFile(filename, Nothing)
acroForm = m_CurDoc.AcroForm()
acroForm.FlattenAllFields() 'this line should flatten the PDF but the saved PDF(flattened.pdf) is not flatten. How can we achieve this?
m_CurDoc.WriteToFile(filename2)
We have license for the PDFXEdit version of the dll. It is highly appreciated if you can tell a way to do this using the PDF Xchange editor API’s. The below code is written in Vb.net.
Dim filename As String = "C:\pdf-to-flatten.pdf"
Dim filename2 As String = "C:\flattened.pdf"
Dim m_CurDoc As PDFXCoreAPI.IPXC_Document
Dim pdfInst As PDFXCoreAPI.PXC_Inst
Dim acroForm As PDFXCoreAPI.IPXC_AcroForm
pdfInst = New PDFXCoreAPI.PXC_Inst()
pdfInst.Init("")
m_CurDoc = pdfInst.OpenDocumentFromFile(filename, Nothing)
acroForm = m_CurDoc.AcroForm()
acroForm.FlattenAllFields() 'this line should flatten the PDF but the saved PDF(flattened.pdf) is not flatten. How can we achieve this?
m_CurDoc.WriteToFile(filename2)
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Flattening with PDFXEditCore.x86.dll
Hello sbensen,
Try using the Editor SDK's https://sdkhelp.pdf-xchange.com/vi ... ts_flatten operation. There is a code sample on how to use that.
Cheers,
Alex
Try using the Editor SDK's https://sdkhelp.pdf-xchange.com/vi ... ts_flatten operation. There is a code sample on how to use that.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Flattening with PDFXEditCore.x86.dll
Hi,
A response to this post was this link https://sdkhelp.pdf-xchange.com/vi ... ts_flatten.
But how can I open a PDF from a filepath, flatten it and save the file. Is this possible in PDFXedit?
If possible can you provide the code , I need to accomplish something similar to this.
Dim doc As PDFXEdit.IPXV_Document = Nothing
Dim strPDFFileName As String = String.Empty
Dim pSInt As PDFXEdit.IPXS_Inst
Dim inst As PDFXEdit.PXV_Inst
Dim pagesCnt, i, j As UInt64
Dim annot As PDFXEdit.IPXC_Annotation
Dim page As PDFXEdit.IPXC_Page
Dim nSquareAtom As UInteger
Dim annotsCnt As UInteger
Dim nID As Integer
Dim op As PDFXEdit.IOperation
Dim input As PDFXEdit.ICabNode
Dim options As PDFXEdit.ICabNode
Try
strPDFFileName = "C:\Files\samplefile.pdf"
oPDFCtrl.OpenDocFromPath(strPDFFileName)
doc = oPDFCtrl.Inst.Doc(0)
inst = New PDFXEdit.PXV_Inst
pSInt = inst.GetExtension("PXS")
nSquareAtom = pSInt.StrToAtom("Square")
nID = inst.Str2ID("op.annots.flatten", False)
op = inst.CreateOp(nID)
input = op.Params.Root("Input")
inst.ShowOpenFilesDlg()
pagesCnt = doc.CoreDoc.Pages.Count
For i = 0 To pagesCnt
page = doc.CoreDoc.Pages(i)
annotsCnt = page.GetAnnotsCount()
For j = 0 To annotsCnt
annot = page.GetAnnot(j)
If (annot.Type = nSquareAtom) Then
input.Add().v = annot
End If
Next
Next
options = op.Params.Root("Options")
options("NonPrintableAction").v = "Flatten"
options("FieldsAction").v = "LeftAsIs".
op.Do()
Catch ex As Exception
Throw
End Try
End Sub
Thanks,
A response to this post was this link https://sdkhelp.pdf-xchange.com/vi ... ts_flatten.
But how can I open a PDF from a filepath, flatten it and save the file. Is this possible in PDFXedit?
If possible can you provide the code , I need to accomplish something similar to this.
Dim doc As PDFXEdit.IPXV_Document = Nothing
Dim strPDFFileName As String = String.Empty
Dim pSInt As PDFXEdit.IPXS_Inst
Dim inst As PDFXEdit.PXV_Inst
Dim pagesCnt, i, j As UInt64
Dim annot As PDFXEdit.IPXC_Annotation
Dim page As PDFXEdit.IPXC_Page
Dim nSquareAtom As UInteger
Dim annotsCnt As UInteger
Dim nID As Integer
Dim op As PDFXEdit.IOperation
Dim input As PDFXEdit.ICabNode
Dim options As PDFXEdit.ICabNode
Try
strPDFFileName = "C:\Files\samplefile.pdf"
oPDFCtrl.OpenDocFromPath(strPDFFileName)
doc = oPDFCtrl.Inst.Doc(0)
inst = New PDFXEdit.PXV_Inst
pSInt = inst.GetExtension("PXS")
nSquareAtom = pSInt.StrToAtom("Square")
nID = inst.Str2ID("op.annots.flatten", False)
op = inst.CreateOp(nID)
input = op.Params.Root("Input")
inst.ShowOpenFilesDlg()
pagesCnt = doc.CoreDoc.Pages.Count
For i = 0 To pagesCnt
page = doc.CoreDoc.Pages(i)
annotsCnt = page.GetAnnotsCount()
For j = 0 To annotsCnt
annot = page.GetAnnot(j)
If (annot.Type = nSquareAtom) Then
input.Add().v = annot
End If
Next
Next
options = op.Params.Root("Options")
options("NonPrintableAction").v = "Flatten"
options("FieldsAction").v = "LeftAsIs".
op.Do()
Catch ex As Exception
Throw
End Try
End Sub
Thanks,
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Flattening with PDFXEditCore.x86.dll
Hello sbensen,
The operation takes either the document or an array of the needed annotations. You will need the IPXV_Document or IPXC_Document depending on whether you need to open it visually or not. After using methods like OpenDocFromPath, you will obtain the needed interface that you need to pass as the operation's input. Then, fill of the needed options and launch the operation. After all of this - use the Write/Save method for the document and if you have opened it via the IPXC level, do not forget to Close() the document.
Cheers,
Alex
The operation takes either the document or an array of the needed annotations. You will need the IPXV_Document or IPXC_Document depending on whether you need to open it visually or not. After using methods like OpenDocFromPath, you will obtain the needed interface that you need to pass as the operation's input. Then, fill of the needed options and launch the operation. After all of this - use the Write/Save method for the document and if you have opened it via the IPXC level, do not forget to Close() the document.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ