Strange PDF Behavior
Posted: Mon Nov 09, 2015 8:52 pm
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;
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;