Strange PDF Behavior

This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-Tools SDK of Library DLL functions(only) - Please use the PDF-XChange Drivers API SDK Forum for assistance with all PDF Print Driver related topics or PDF-XChange Viewer SDK if appropriate.

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Post Reply
DolphinMann
User
Posts: 158
Joined: Mon Aug 04, 2014 7:34 pm

Strange PDF Behavior

Post by DolphinMann »

I have a PDF, which when I open in PDF X-Change Viewer, claims to be corrupted, but it does not provide a great deal of information as to why(screenshot below). If I then save this PDF and work with it via the SDK I have no problems.

However, if I load this PDF via the SDK and attempt to do anything with it, when I save it is removing much of the visual information at the top and bottom of the page. I've even isolated all complicated code to just a few simple lines of open->save->close essentially and I am able to replicate it every time.

So my questions are:

1.) Is there a way to tell what is corrupt or why it is corrupt?
2.) Why when I open it via PDF X-Change viewer and hit save does it "fix" the corruption and PDF, but doing the same activity through code using the SDK does not?

Sample code, obviously I've left my dev keys out and the path to the file is valid on my system. The code is in C#

int pdfObject = 0;
XCPro35_Defs.PXCp_Init(out pdfObject, g_RegKey, g_DevCode);
int result = XCPro35_Defs.PXCp_ReadDocumentW(pdfObject, @"C:\Users\mark.mann\Desktop\test\HurtingPDFs\FATTURAINVOICE-46441-1-069742-del-27-10-2015.pdf", 0);
result = XCPro35_Defs.PXCp_WriteDocumentW(pdfObject, @"C:\Users\mark.mann\Desktop\test\HurtingPDFs\FML.pdf",
XCPro35_Defs.PXCp_CreationDisposition.PXCp_CreationDisposition_Overwrite, ((int)XCPro35_Defs.PXCp_WriteDocFlag.PXCp_Write_NoRelease));
XCPro35_Defs.PXCp_Delete(pdfObject);
pdfObject = 0;
Attachments
FATTURAINVOICE-46441-1-069742-del-27-10-2015.pdf
(267.91 KiB) Downloaded 279 times
DolphinMann
User
Posts: 158
Joined: Mon Aug 04, 2014 7:34 pm

Re: Strange PDF Behavior

Post by DolphinMann »

For some reason the image didn't upload. Nevermind, it keeps telling me JPG/BMP/PNG are not allowed.

It's just a screenshot of the PDF X-Change end user application while viewing the attached PDF file. It clearly says that it is corrupt in the lower left corner with the little warning sign, but it does not say why and I can simply overwrite save within the application and then it fixes the problem.

Edit: Also attaching the results of the sample code above so the difference can be seen between the two PDF's
Attachments
FML.pdf
(13.3 KiB) Downloaded 288 times
User avatar
Lzcat - Tracker Supp
Site Admin
Posts: 677
Joined: Thu Jun 28, 2007 8:42 am

Re: Strange PDF Behavior

Post by Lzcat - Tracker Supp »

Your file is invalid, and SDKs older that Editor/CoreAPI (and Viewer, which is replaced by the Editor SDK) does not handle broken files correctly.
If you need detailed info - file contain streams with no Length specified (which is required by PDF specification). For example this is begining of first object in file (stream):

Code: Select all

2 0 obj
<< /Type /XObject
/Subtype /Image
/Width 1134
/Height 469
/ColorSpace /DeviceRGB
/BitsPerComponent 8
/Filter /DCTDecode
/Interpolate true
>>
stream
Victor
Tracker Software
Project manager

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
DolphinMann
User
Posts: 158
Joined: Mon Aug 04, 2014 7:34 pm

Re: Strange PDF Behavior

Post by DolphinMann »

That is exactly what I was looking for. Thank you.

I take it you also recommend I update my code to use the Editor SDK? I guess in short my question would be:

Is there a way to replicate the process of opening the admittedly corrupt PDF in PDF X-Change Viewer and clicking "save" via background(non-GUI) code? Are you saying I should migrate my PDF code to use the editor SDK? Or is the Editor SDK just a replacement for the Viewer SDK? I'm fine with a link to the differences between all of these products. My code is a year or so old now and I doubt my libraries have been updated since I first created the project.


EDIT: I have been reading up on the new SDK's....what are the options for someone who has purchased SDK Pro, and while I found some comparisons to Editor SDK vs. Core API SDK there was not much comparing those two(or I guess Editor SDK) vs. SDK Pro(the "old" one)

Can you point me in the right direction to learn more about that difference? I've downloaded the new kits to play with

Actually, just found this thread: https://www.pdf-xchange.com/forum3 ... 67&t=24312

Looks like Core-API can replace Pro SDK free of charge assuming all maintenance is in order. Are there no options for the Editor SDK as far as upgrades or translations?
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17818
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Strange PDF Behavior

Post by Tracker Supp-Stefan »

Hello DolphinMann,

Yes the Core SDK will allow you to manipulate files without UI, and is a good replacement of what you had as tools in the PRO SDK before. The notable exception is that before the Pro SDK included the Viewer SDK, but now the Core one does not include neither the Viewer nor the Editor SDKs.

There are no upgrade paths from Pro to Editor SDK, but if you get your Core SDK license - I believe than then an upgrade to an Editor SDK will show up in your account. (the Core SDK is included in the Editor SDK)

As for the code and reusability - I am afraid that the Editor and Viewer are totally different products, and rewriting some of your code will be necessary.

I hope this clarifies the situation, but if it does not - please do not hesitate to ask any further questions you might have!

Regards,
Stefan
Post Reply