Print a PDF to PDF via SDK  SOLVED

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
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Print a PDF to PDF via SDK

Post by zarkogajic »

Hi Support,

Having a PDF document with some security restrictions like "no page extraction", but "allow printing", I'm looking for a way to print a PDF to PDF - as the resulting PDF will be without restrictions.

I can do this in EU Editor, by printing the document via "PDF-XChange Lite Printer" - as it gets installed along with EU Editor. Actually, the same can be achieved if the selected PDF printer is any PDF virtual printer (like Adobe PDF Printer).

Is there a way to print a PDF to PDF using SDK (to achieve the above), silently (so no print dialog), just by specifying the resulting file name? And of course, without having the "PDF-XChange Lite Printer" (or any) installed.



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

Re: Print a PDF to PDF via SDK

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

There is a sample in the FullDemo application on how to use the Print operation via the Print Form. You can then set the needed settings and then extract the needed code piece and use the op.document.printPages operation.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Print a PDF to PDF via SDK

Post by zarkogajic »

Hi Alex,

Thanks. But for "op.document.printPages" I still need a virtual PDF printer installed, correct?

I was hoping for something like : use op.document.printPages to create a new CoreDocument .

So, in the similar way how, for example, the SDK, via converters, can open a DOC and convert (/print) to PDF.

Btw, "Input" and "Output" parameters are used or not for this operation?

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

Re: Print a PDF to PDF via SDK

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

The FullDemo application has a sample form that has printer choose dropdown and you can look at all of the parameters there also.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Print a PDF to PDF via SDK

Post by zarkogajic »

HI Alex,

Thanks. Yes, I see that,

I'm asking for something else... note that I do not want to pick the installed printer (as I might not have one)

I'm looking for a "converter" that knows how to *print* a PDF to PDF.


-žarko
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2352
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: Print a PDF to PDF via SDK

Post by Vasyl-Tracker Dev Team »

Hi zarko.

Unfortunately, there is no such simple PDF-to-PDF_without_restrictions converter. And to be clear - it is against to PDF-security to have such thing in SDK.

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.
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Print a PDF to PDF via SDK

Post by zarkogajic »

Hi Vasyl,

Thanks. Yes, I know what I'm up to is kind of against the security .

But, if a document allows printing, and I can print it using "pdfx lite printer" (or any pdf printer) - then is that apprach also against what should be disallowed?


-žarko
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2352
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: Print a PDF to PDF via SDK

Post by Vasyl-Tracker Dev Team »

Technically it is impossible to prevent using the virtual printers by the app. From the app's prospective such printers look like real ones.
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.
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Print a PDF to PDF via SDK

Post by zarkogajic »

Hi Vasyl,

Of course, I do agree with what you are saying.

However, the entire thing depends on the point of view and perspective :)

PDF Printers are nothing but applications knowing how to open and manipulate PDF documents (and of course other supported formats).

Once a PDF Printer receives a PDF for input, to create a new PDF ("printed version"), the printing app must extract pages and stuff from the pdf received. So, a pdf printer app also does not really obey the security settings and does extract pages (content from it) to create a new PDF.

there is no such simple PDF-to-PDF_without_restrictions converter.
Is there a complex one? :)

By a quick look in Help, I'm guessing something can be achieved with IIXC_Page and related...


-žarko
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2352
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: Print a PDF to PDF via SDK

Post by Vasyl-Tracker Dev Team »

Hi Zarko.
Once a PDF Printer receives a PDF for input, to create a new PDF...
That's incorrect. Actually the PDF-printer only receive printing commands (GDI) like:

Code: Select all

StartDoc
  StartPage
      DrawText(text, x, y... )
      MoveTo(x, y... )
      LineTo(x, y... )
      ...
  EndPage
...
EndDoc
The same is for real printers too. And only PostScript-printer may receive the native PostScript content in case when printing app is able to convert document to postscript format (we haven't such option).
I'm guessing something can be achieved with IIXC_Page and related...
Yes, you may 'convert' all pages from source doc to new doc via something like:

Code: Select all

for (page : srcDoc.Pages)
{
     newPage = newDoc.Pages.InserPage(-1, page.Box[PBox_MediaBox] .. );
     // copy content
     con = srcPage.GetContent(CAccessMode_Readonly);
     newPage.PlaceContent(CAccessMode_FullClone, con);
     // then copy comments using srcPage.GetAnnotsCount/GetAnnot... 
}
- additionally you need to copy bookmarks tree. When there are bookmarks that relates to named-destinations - you also need to handle corresponding named tree.
- also biggest problem is - it seems impossible to copy existing AcroForm in such way. Because it is too complex stuff in common case.

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.
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Print a PDF to PDF via SDK  SOLVED

Post by zarkogajic »

Hi Vasyl,

Thank for the input.

-žarko
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17823
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Print a PDF to PDF via SDK

Post by Tracker Supp-Stefan »

:)
Post Reply