We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Problem Flattening some PDFs

we have some functionality set up to allow a user to upload their pdfs and drop an image jpeg, jpg, png as a signature and then we flatten the document. most of the documents that are used work fine, but we have come across the rare case where when we flatten specific documents the signature image seems to disappear but its actually getting moved and squished down to the wrong dimensions.

we suspect that the pdfs might have Un-flattened layers, when opening the document in microsoft pdf viewer and printing it as pdf again, everything works as expected with flattening on a signature.

has this issue been seen before? is there a way to identify these bad pdfs? i.e. if they already have layers so we can skip them?


EDIT:
upon further research could this be related to the pdf format version, the document that didnt work was PDF1.4 while the ones that are flattening correctly are PDF1.7


11 Replies 1 reply marked as answer

CT Corey Thornton November 4, 2022 03:23 PM

It seems that the version may be the issue but I cant get the version to stay, it always reverts back to 1.4
this is my current set up


            memoryStream.Position = 0;

            PdfLoadedDocument loadedDocument = new PdfLoadedDocument(memoryStream);

            if(loadedDocument.FileStructure.Version < PdfVersion.Version1_7)

            {

                PdfFileStructure structure = new PdfFileStructure();

                structure.CrossReferenceType = PdfCrossReferenceType.CrossReferenceStream;

                structure.Version = PdfVersion.Version1_7;

                loadedDocument.FileStructure = structure;

            }

            loadedDocument.Save(tempStream);

            tempStream.Position = 0;

            loadedDocument = new PdfLoadedDocument(tempStream);





IJ Irfana Jaffer Sadhik Syncfusion Team November 7, 2022 07:54 AM

We are unable to reproduce the reported behavior on our end. since this issue randomly occurred on your side, we request you to share the simple sample, input document, product version, and environment details (OS, Bit version, and culture settings) with us. So, that we can analyze further and provide details on this.



CT Corey Thornton November 7, 2022 08:42 AM

Hey thanks for the follow up.
im not sure if I can share the document with you just now as it is an unfiled legal document. 

im more focused on my follow up question in the reply above, I've tried changing the file version but after I save the file it remians as 1.4 instead of 1.7



CT Corey Thornton November 7, 2022 09:17 AM

Just followed up with my team, yea this is a secure document so I cannot upload, and I have no way to generate a 1.4 document. So if I can just confirm the proper way to change a file version and save it that would give me the answer I need to resolve our problem



CT Corey Thornton November 7, 2022 02:25 PM

I have gotten it to work by changing incrementalUpdate to false while creating the fileStructure object.

there is one last problem, after I successfully convert I add an image annotation before it is flattened it looks correct but after I flatten it is shifted over many pixels to the left, have you seen this issue 



IJ Irfana Jaffer Sadhik Syncfusion Team November 9, 2022 07:47 AM

We have tried to reproduce the reported issue with the provided details on our end. But it is working properly on our end. We have attached the sample with our test documents for your reference. Please try this in your end and let us know the result.

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ra/NetCoreSample1149819372

If still you're facing the issue, we request you to share the modified sample, product version with us. so that we can assist with you further in this.



CT Corey Thornton replied to Irfana Jaffer Sadhik November 9, 2022 02:38 PM

Hello, I am zipping up the original sample you provided me with, with some slight modifications (changed target framework to 5.0, and modified code to read in a file)

in the sample will be a samplePDF from the user who is having problems when trying that file out on the given sample provided you will notice that the image is being flatted on the top left corner as if the document is in landscape mode when looking at the file properties through syncfusion it showed that it does however see it as portrait mode

For added context this user is scanning a document into a PDF 


Attachment: NetCoreSample_c3972460.7z



IJ Irfana Jaffer Sadhik Syncfusion Team November 10, 2022 09:02 AM

We have tried to reproduce the reported behavior with the provided details on our end and got the following output. we request you to check and confirm whether you are facing the same issue on your end.



However, we will proceed to validate this and provide further details on November 11th, 2022.




CT Corey Thornton replied to Irfana Jaffer Sadhik November 10, 2022 09:03 AM

yes correct. That is the exact issue



IJ Irfana Jaffer Sadhik Syncfusion Team November 11, 2022 08:14 AM

On our further analysis, drawing image appearance for 0 degrees left top position and 90 degrees right top position and 180-degree right bottom, and 270 degrees left bottom position. This is our behavior of interactive field objects for rotated PDF documents. We updated the sample to meet your requirement by rotating the signature appearance look based on the page rotation angle. Please try the modified sample below on your end and let us know if you have any further assistance with this.

 

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/NetCoreSample1483371517


Marked as answer

CT Corey Thornton replied to Irfana Jaffer Sadhik November 15, 2022 08:54 AM

This solution makes sense for adding and flattening an image.

however in our usual workflow we drag and drop an image without flattening on the angular ejs pdfviewer first and flatten later.

right now in the document and page properties it say the pdf is in portrait mode but has a rotation of 270. is there any way to reset the document so that its pages are actually in portrait mode with a rotational angle of 0?


Loader.
Live Chat Icon For mobile
Up arrow icon