NewDocumentEx - pdfa

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
Mpoor
User
Posts: 7
Joined: Wed Feb 20, 2019 10:52 pm

NewDocumentEx - pdfa

Post by Mpoor » Wed Feb 20, 2019 11:08 pm

Hi!

I created a cpp application that uses the PDF-XChange Core API SDK.
It just creates a new document, puts some lines in it and saves it.
I'm using IPXC_Inst::NewDocument to create the document.
I read that I could use IPXC_Inst::NewDocumentEx with an ICab* parameter to save this newly created document in pdfa.

Could you show me please how to set this ICab's pdfstandard property? I couldn't find anything about ICabs in the documentation.

Thanks,

Michael

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

Re: NewDocumentEx - pdfa

Post by Sasha - Tracker Dev Team » Thu Feb 21, 2019 8:00 am

Hello Michael,

Please look at this topic:
viewtopic.php?f=67&t=26786

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

Mpoor
User
Posts: 7
Joined: Wed Feb 20, 2019 10:52 pm

Re: NewDocumentEx - pdfa

Post by Mpoor » Thu Feb 21, 2019 8:30 am

Hello Alex!

Thanks for the fast answer. I checked the post but I still have some questions.
I'm going to use the Editor SDK and load the pdfa plugin.
Do I have to create a pdf file then convert it to pdfa, or can I simply just create a new file and save it with pdfa?

Thanks,

Michael

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

Re: NewDocumentEx - pdfa

Post by Sasha - Tracker Dev Team » Thu Feb 21, 2019 8:53 am

Hello Michael,

Please use forum search first - many questions are already answered:
viewtopic.php?f=66&t=31385&p=127658&hilit=pdfa#p126915

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

Mpoor
User
Posts: 7
Joined: Wed Feb 20, 2019 10:52 pm

Re: NewDocumentEx - pdfa

Post by Mpoor » Thu Feb 21, 2019 2:30 pm

Dear Alex!

I read these posts, searched the forum and tried everything I found but I couldn't generate a PDF/A-1a document.
Here's the code I have right now:

IPXV_Inst* ipxvInst;
//Initialized IPXV_Inst* and loaded pdfa plugin
//Added a page, and put some content in it with lineto/moveto through IPXC_ContentCreator
//Then when I want to save the file:
IUnknown* spUnk;
ipxvInst->GetExtension(L"AFS", &spUnk);
PXV::IAFS_Inst* fsInst = (PXV::IAFS_Inst*)spUnk;
PXV::IAFS_Name* destPath = nullptr;
PXV::IAFS_FileSys* filesys = nullptr;
fsInst->get_DefaultFileSys(&filesys);
filesys->StringToName(L"c:\\...\\pdfatest.pdf", 0, NULL, &destPath);
int openFileFlags = (int)(PXV::AFS_OpenFileFlags::AFS_OpenFile_CreateAlways | PXV::AFS_OpenFileFlags::AFS_OpenFile_Read | PXV::AFS_OpenFileFlags::AFS_OpenFile_Write | PXV::AFS_OpenFileFlags::AFS_OpenFile_FullCache);
PXV::IAFS_File* destFile = nullptr;
filesys->OpenFile(destPath, openFileFlags, nullptr, nullptr, &destFile);

PXV::IPXV_ExportConverter* cnv = nullptr;
PXV::ULONG_T max = 0;
ipxvInst->get_ExportConvertersCount(&max);
for (PXV::ULONG_T i = 0; i < max; i++)
{
PXV::IPXV_ExportConverter* tempcnv = nullptr;
ipxvInst->get_ExportConverter(i, &tempcnv);
BSTR getstr = L"";
BSTR pdfastr = L"conv.exp.pdfa";
tempcnv->get_ID(&getstr);
if (!wcscmp(getstr, pdfastr))
ipxvInst->get_ExportConverter(i, &cnv);
}
if (cnv != nullptr)
{
PXV::ICab* cab = nullptr;
PXV::ICabNode* cabnode = nullptr;
ipxvInst->GetFormatConverterParams(VARIANT_FALSE, L"conv.exp.pdfa", &cab);
cab->get_Root(&cabnode);
hr = cabnode->SetInt(L"Part", 2);
hr = cabnode->SetInt(L"Conformance", 1);
hr = cnv->Convert(ipxvInst, m_pDoc, destFile, 0, cab, NULL, 0, NULL, NULL);
}
m_pDoc->WriteTo(destFile, NULL, 0);

The file is created but it's version is still PDF 1.7

Can you help me out here please?

Thanks,

Michael

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

Re: NewDocumentEx - pdfa

Post by Sasha - Tracker Dev Team » Thu Feb 21, 2019 2:53 pm

Hello Michael,

This should already save to the needed file - no need to Write afterwards:

Code: Select all

hr = cnv->Convert(ipxvInst, m_pDoc, destFile, 0, cab, NULL, 0, NULL, NULL);
Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

Mpoor
User
Posts: 7
Joined: Wed Feb 20, 2019 10:52 pm

Re: NewDocumentEx - pdfa

Post by Mpoor » Thu Feb 21, 2019 3:20 pm

Thanks Alex!

Works like a charm!

Thanks,

Michael

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

Re: NewDocumentEx - pdfa

Post by Sasha - Tracker Dev Team » Thu Feb 21, 2019 3:27 pm

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

Post Reply