How can I open a PDF file as IPXV_Document?

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, 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
baumunk
User
Posts: 38
Joined: Fri Nov 13, 2020 8:47 am

How can I open a PDF file as IPXV_Document?

Post by baumunk »

I need IPXV_Document for the following code example:

https://sdkhelp.pdf-xchange.com/view/PXV:op_document_OCRPages
and
https://sdkhelp.pdf-xchange.com/view/PXV:IPXV_Document_Save

IPXV_Document has only Save function

"op.openDoc"

https://sdkhelp.pdf-xchange.com/view/PXV:op_openDoc

is only IPXC_Document but not IPXV_Document...

best regards
Ernest Baumunk
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How can I open a PDF file as IPXV_Document?

Post by Sasha - Tracker Dev Team »

Hello baumunk,

You can also use the IPXC_Document for the given operation. Also, you can use the IPXC_Document::WriteToFile to save the needed Core Document.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
baumunk
User
Posts: 38
Joined: Fri Nov 13, 2020 8:47 am

Re: How can I open a PDF file as IPXV_Document?

Post by baumunk »

Hello Alex,

IPXC_Document::WriteToFile works.

But not with this example:
https://sdkhelp.pdf-xchange.com/view/PXV:IPXV_Document_Save

Code:

Code: Select all

//Saving document as pdfa (for this the PDFA plugin should be registered)
	PDFXEdit.IPXV_ExportConverter cnv = null;
	for (uint i = 0; i < pdfCtl.Inst.ExportConvertersCount; i++)
	{
		if (pdfCtl.Inst.ExportConverter[i].ID == "conv.exp.pdfa")
			cnv = pdfCtl.Inst.ExportConverter[i];
	}
	if (cnv != null)
	{
		PDFXEdit.ICab cab = pdfCtl.Inst.GetFormatConverterParams(false, "conv.exp.pdfa");
		pdfCtl.Doc.Save(destPath, 0, null, cnv, cab);
	}
There it is necessary to use IPXV_Document

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

Re: How can I open a PDF file as IPXV_Document?

Post by Sasha - Tracker Dev Team »

Hello baumunk,

The IPXV_Document is a document opened in the IPXV_Control. IPXC_Document is a document opened on the Core level, without any visual representations.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
baumunk
User
Posts: 38
Joined: Fri Nov 13, 2020 8:47 am

Re: How can I open a PDF file as IPXV_Document?

Post by baumunk »

Hello Alex,

With IPXV_Document pdf, opened via IPXV_Control both OCR and DPF/A work now but only PDF/A 2B.
And it shows progress window and hint window for PDF/A.

But how can I convert to PDF/A file as IPXC_Document object?

I have not found anything suitable in https://sdkhelp.pdf-xchange.com/view/PXV:PXC.

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

Re: How can I open a PDF file as IPXV_Document?

Post by Sasha - Tracker Dev Team »

Hello baumunk,

Well for that you should use the IPXV_ExportConverter::Convert method - there you should pass the IPXC_Document along with other params.
Also, there is this sample here:
viewtopic.php?p=104006#p104006

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
baumunk
User
Posts: 38
Joined: Fri Nov 13, 2020 8:47 am

Re: How can I open a PDF file as IPXV_Document?

Post by baumunk »

Hello Alex


The example:
viewtopic.php? p = 104006 # p104006

but is only for IPXV_Document
it does not work with IPXC_Document.
IPXC_Document does not have a save function ... only WriteToFile

Example with IPXV_Document

Code: Select all

void PDFA(PDFXEdit.IPXV_Document doc)
        {
            PDFXEdit.IAFS_Inst fsInst = (PDFXEdit.IAFS_Inst)Inst.GetExtension("AFS");
            PDFXEdit.IAFS_Name destPath = fsInst.DefaultFileSys.StringToName(testfile_pdfa); //Converting string to name
            doc.Save(destPath, (int)PDFXEdit.PXV_DocSaveFlags.PXV_DocSave_NoProgress);
            //Saving document as pdfa (for this the PDFA plugin should be registered)
            PDFXEdit.IPXV_ExportConverter cnv = null;
            for (uint i = 0; i < pdfCtl.Inst.ExportConvertersCount; i++)
            {
                if (pdfCtl.Inst.ExportConverter[i].ID == "conv.exp.pdfa")
                    cnv = pdfCtl.Inst.ExportConverter[i];
            }
            if (cnv != null)
            {
                PDFXEdit.ICab cab = pdfCtl.Inst.GetFormatConverterParams(false, "conv.exp.pdfa");
                doc.Save(destPath, 0, null, cnv, cab);
            }
        }
Example with IPXC_Document:

Code: Select all

private void SaveDocument2(PDFXEdit.IPXC_Document doc, string filename)
        {
            PDFXEdit.IPXV_ExportConverter cnv = null;
            for (uint i = 0; i < pdfCtl.Inst.ExportConvertersCount; i++)
            {
                if (pdfCtl.Inst.ExportConverter[i].ID == "conv.exp.pdfa")
                    cnv = pdfCtl.Inst.ExportConverter[i];
            }
            if ((cnv == null) || (pdfCtl.Doc == null))
                return;
            PDFXEdit.ICab cab = pdfCtl.Inst.GetFormatConverterParams(false, "conv.exp.pdfa");
            PDFXEdit.ICabNode convParamsRoot = cab.Root;
            //<!-- 1 - PDF/A-1; 2 - PDF/A-2; 3 - PDF/A-3 -->
            //<Item id="Part" type="Int" defVal="2" />
            //<!-- 0 - -a; 1 - -b; 2 - -u; -->
            //<Item id="Conformance" type="Int" defVal="1" />
            //This will do PDF/A-2b
            convParamsRoot.SetInt("Part", 2);
            convParamsRoot.SetInt("Conformance", 1);
            convParamsRoot.SetInt("ShowReport", 0);
            convParamsRoot.SetString("ErrorMessage", "false");
            PDFXEdit.IString name = pdfCtl.Inst.CreateString("D:\\TestFile_res.pdf");
           Here is Error=>  doc.Save(name, 0, null, cnv, cab);
        }
Ernest
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How can I open a PDF file as IPXV_Document?

Post by Sasha - Tracker Dev Team »

Hello baumunk,
Well for that you should use the IPXV_ExportConverter::Convert method - there you should pass the IPXC_Document along with other params.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
baumunk
User
Posts: 38
Joined: Fri Nov 13, 2020 8:47 am

Re: How can I open a PDF file as IPXV_Document?

Post by baumunk »

Hello Alex,

Thanks, I didn't understand right away.
But it works now.

One last little question.

OCR recognition and conversion to PDF / A 2B afterwards takes comparatively slowly.

An example file. Samle_pages he needs 4 sec for OCR and 5 for PDF / A.

With larger ones (unfortunately I cannot provide them) up to 18 sec.

With OCR from SDK Pro (OCR_MakeSearchable) it is 6 times faster. Why?

Mfg Ernest Baumunk
sample_pages.rar
(91.58 KiB) Downloaded 53 times
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2353
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: How can I open a PDF file as IPXV_Document?

Post by Vasyl-Tracker Dev Team »

Hi Ernest.

Sorry for big delay with it. Just checked the 358 build with your sample_pages.pdf and OCR, OCR+PDF/A-2B - everything works fine and pretty fast on my side (0.5-1 sec per page for OCR/PDFA). Can you confirm that you still have the same problems with 358 too?

Cheers.
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Post Reply