Aspose PDF content(text) gets distorted when pdf is resized


#1

Hello,
I want to convert an HTML page into pdf. Whenever I’m resizing the pdf document the text/ contents inside it gets distorted. Below the code snippet is given. Your help will be much appreciated.

Thank you.

Code snippet:

                 // var document = here document is instantiated
                PdfFileEditor editor = new PdfFileEditor();                   

                PdfFileEditor.ContentsResizeParameters parameters = new 
                PdfFileEditor.ContentsResizeParameters(
                PdfFileEditor.ContentsResizeValue.Units(0),
                PdfFileEditor.ContentsResizeValue.Units(PageSize.PageLetter.Width), 
                PdfFileEditor.ContentsResizeValue.Units(0), 
                PdfFileEditor.ContentsResizeValue.Units(0),
                PdfFileEditor.ContentsResizeValue.Units(PageSize.PageLetter.Height),
                PdfFileEditor.ContentsResizeValue.Units(0));


                PdfPageEditor pdfPageEditor = new PdfPageEditor();
                pdfPageEditor.BindPdf(document);
                pdfPageEditor.PageSize.Width = PageSize.PageLetter.Width;
                pdfPageEditor.PageSize.Height = PageSize.PageLetter.Height;
                pdfPageEditor.VerticalAlignmentType = VerticalAlignment.Center;
                pdfPageEditor.HorizontalAlignment = HorizontalAlignment.Justify;
               
                pdfPageEditor.Save(stream);
               
            
                int[] pages = new int[document.Pages.Count];
                for(int i = 0; i<document.Pages.Count; i++)
                {
                    pages[i] = i + 1;
                }

                editor.ResizeContents(document, pages, parameters);

                document.Save(outputPdfFilePath + "ContentsResized.pdf");

#2

@ittahadakash1

Thank you for contacting support.

Would you please share source and generated file as ZIP so that we may try to reproduce and investigate it in our environment.


#3

Hello,

I have attached the required files. There are 2 files in the zipped folder. 1st is the HTML file which will be the “input” and the 2nd one is the “current output”.

I have specified the width and the height of the ‘body’ tag inside the HTML document. But the width is not maintained on the final output. I want the output file to be exactly like the input file. Please let me know if you can fix this.

Thank you.

Test Files.zip (291.3 KB)


#4

@ittahadakash1

The PDF document Current_Output.pdf appears same as the HTML displayed by a browser. However, the dimensions of contents are updated automatically when you are resizing the contents, so we are afraid the values in source HTML may not be maintained because of resizing.


#5

Even if I don’t resize the contents, the width value of the source HTML is not maintained on the PDF. No matter what, the final output PDF gets very wide in dimension.

I want the output PDF to be of A4 paper size. All the contents inside the HTML should resize according to the A4 output PDF itself. Can you please replicate the given input html into an A4 paper sized PDF and check the output if that is actually possible?

If it’s possible can you please provide the output PDF that you have generated from your machine. After the verification we will be able to purchase the license for the product.

N.B: Using Aspose.Words I am able to create A4 size PDF with all the contents correctly fitting inside. But all the checkbox field is not being converted according to the given CSS. Here I am attaching the PDF generated with Aspose.Words.

File Converted With Aspose Words.pdf (173.0 KB)

Thanks.


#6

@ittahadakash1

Thank you for elaborating further.

We have logged a ticket with ID PDFNET-47237 in our issue management system for further investigations. We will let you know once any update will be available in this regard.


#7

@Farhan.Raza Is there any update on this issue?

Thank you.


#8

@ittahadakash1

Please note that the issue has been logged under free support model and will be investigated on first come first serve basis. Therefore, it may take some months to resolve. As soon as we have some definite updates regarding ticket resolution, we will let you know.

Moreover, we also offer paid support model where issues are resolved on urgent basis and have priority over the issues logged under free support model. You may check our Paid Support options for your reference.