Exporting images from PdfLoadedDocument - font problem

Good morning,

I am using the ExportAsImage method of PdfLoadedDocument for a while now - works perfectly most of the time!

I have a set of documents that are creating problems.
They are displayed and printed correctly in Acrobat and other PDF viewers.
But after applying ExportAsImage, everything printed in the "Courier bold" font is corrupted.

Problem is: this PDF is created in a "old, legacy app" which is not maintained any longer.
So I cannot create the PDF "using another way" :-(

I have attached 2 documents in a zip file:
  1. TestRaster.PDF - the original document
  2. TestRaster_raster.PDF - a pdf containing all pages from the source document as rastered images

As you can see, all lines in 2. using the "Courier bold" are corrupted.

Strangely enough, I am using this code ...


... to raster complex documents, including different fonts, graphics, etc - but with this font I am stuck!

Please, do you have any idea to solve this issue ?

Regards
Gerhard


Attachment: TestRaster_d33e3c1a.zip

4 Replies

GG Gerhard Galantha February 14, 2018 07:29 AM UTC

sorry, forgotten ...

This is the code I am using to convert a pdf into a pdf with rastered pages:

                using (Syncfusion.Pdf.Parsing.PdfLoadedDocument pdfDoc = new Syncfusion.Pdf.Parsing.PdfLoadedDocument(PdfInPath))
                using (Syncfusion.Pdf.PdfDocument rasterPdfDoc = new Syncfusion.Pdf.PdfDocument())
                {
                    rasterPdfDoc.PageSettings.Margins.All = 0;

                    for (int page = 0; page < pdfDoc.Pages.Count; page++)
                    {
                        Syncfusion.Pdf.PdfPageRotateAngle rotation = pdfDoc.Pages[page].Rotation;
                        float width = pdfDoc.Pages[page].Size.Width; float height = pdfDoc.Pages[page].Size.Height;
                        float maxSize = Math.Max(width, height); float minSize = Math.Min(width, height);

                        bool landscape = !((rotation == Syncfusion.Pdf.PdfPageRotateAngle.RotateAngle0
                                            || rotation == Syncfusion.Pdf.PdfPageRotateAngle.RotateAngle180)
                                           && (height > width));


                        Bitmap image = landscape
                                       ? pdfDoc.ExportAsImage(page, new SizeF(maxSize, minSize), 300, 300, true)
                                       : pdfDoc.ExportAsImage(page, new SizeF(minSize, maxSize), 300, 300, true);

                        if (landscape)
                        {
                            rasterPdfDoc.PageSettings.Orientation = Syncfusion.Pdf.PdfPageOrientation.Landscape;

                            Syncfusion.Pdf.PdfPage rasterPage = rasterPdfDoc.Pages.Add();
                            Syncfusion.Pdf.PdfPage x = new Syncfusion.Pdf.PdfPage();

                            rasterPage.Graphics.DrawImage(new Syncfusion.Pdf.Graphics.PdfBitmap(image), 0, 0, maxSize, minSize);
                        }
                        else
                        {
                            rasterPdfDoc.PageSettings.Orientation = Syncfusion.Pdf.PdfPageOrientation.Portrait;

                            Syncfusion.Pdf.PdfPage rasterPage = rasterPdfDoc.Pages.Add();
                            Syncfusion.Pdf.PdfPage x = new Syncfusion.Pdf.PdfPage();

                            rasterPage.Graphics.DrawImage(new Syncfusion.Pdf.Graphics.PdfBitmap(image), 0, 0, Math.Min(height, width), Math.Max(height, width));
                        }
                    }

                    rasterPdfDoc.Save(pdfRasterPath);




AK Ayswarya Krishna Kumar Syncfusion Team February 15, 2018 12:51 PM UTC

Hi Gerhard, 
 
We are not able to reproduce the reported issue, “Fonts are not preserved properly while converting the PDF pages to raster images using ExportAsImage() API”. We have tested the scenario with the provided code snippet. Please provide us the sample to reproduce the issue at our end. Also, please confirm us the Essential Studio version that you are using at your end. 
 
Regards, 
Ayswarya 



GG Gerhard Galantha February 15, 2018 01:44 PM UTC

Good afternoon!

The source PDF is TestRaster_Quer.pdf.
The PDF with rastered Pages is TestRaster_Quer_raster.PDF

You will find both files in the attached ZIP.

The version is 14.4450.0.15

Regards
Gerhard

Attachment: TEST_10835fff.zip


AK Ayswarya Krishna Kumar Syncfusion Team February 16, 2018 10:29 AM UTC

Hi Gerhard, 
 
 
A support incident to track the status of the reported issue has been created under your account. Please log on to our support website to check for further updates.

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents 
Regards, 
Ayswarya 


Loader.
Up arrow icon