Flattening with PDFXEditCore.x86.dll

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
sbensen
User
Posts: 3
Joined: Wed Jun 12, 2019 1:27 pm

Flattening with PDFXEditCore.x86.dll

Post by sbensen » Wed Jun 12, 2019 1:31 pm

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.

sbensen
User
Posts: 3
Joined: Wed Jun 12, 2019 1:27 pm

Re: Flattening with PDFXEditCore.x86.dll

Post by sbensen » Wed Jun 12, 2019 8:43 pm

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)

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

Re: Flattening with PDFXEditCore.x86.dll

Post by Sasha - Tracker Dev Team » Thu Jun 13, 2019 6:34 am

Hello sbensen,

Try using the Editor SDK's https://sdkhelp.tracker-software.com/vi ... ts_flatten operation. There is a code sample on how to use that.

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

sbensen
User
Posts: 3
Joined: Wed Jun 12, 2019 1:27 pm

Re: Flattening with PDFXEditCore.x86.dll

Post by sbensen » Thu Sep 19, 2019 2:16 am

Hi,
A response to this post was this link https://sdkhelp.tracker-software.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,

Post Reply