PDF Conversion - Appears to be changing the color and font

for certain PDF’s the PDF conversion is appearing to be changing the Image color and Fonts.

We observed for one PDF the Gradient color is replaced with Solid Black and for some PDF’s Ariel Bold font is replaced with just Ariel

We are suing the DPI method with value as 120,

Any suggestions for this issue. should we make any configuration changes in our conversion method.

@chandrakant.bagewadi,

Please add the code snippet you are using and the PDF document.

The output conversion will also be helpful when trying to research the problem.

Hi,

  • Please refer the below code snippet, We are using the DPI flow -
private void applyPDFConversion(Document pdfDocument, String[] requestData, int pageCount,
                                    String asposeResultFileName) throws IOException {
        OutputStream imageStream = new FileOutputStream(asposeResultFileName);

        // Create Resolution object
        Resolution resolution;

        // Create JpegDevice object with particular resolution
        JpegDevice jpegDevice;

        // Get aspose conversion flow
        AsposeConversionMode resolutionMode = AsposeConversionMode.valueOf(config.getAsposeConversionMode());

        // ******* Use DPI flow *******
        if (resolutionMode == AsposeConversionMode.DPI) {
            resolution = new Resolution(config.getAsposeDpiValue());
            jpegDevice = new JpegDevice(resolution);
        } else if (resolutionMode == AsposeConversionMode.DIMENSION) {

            // ******* Use DIMENSION Flow *******
            int fixedWidth = config.getAsposeFixedWidth();
            int heightCalculated = calculateHeight(fixedWidth,
                    Double.parseDouble(requestData[4]),
                    Double.parseDouble(requestData[5]));
            resolution = new Resolution(fixedWidth, heightCalculated);
            jpegDevice = new JpegDevice(fixedWidth, heightCalculated, resolution);
        } else {
            jpegDevice = new JpegDevice();
        }

        // Convert a particular page and save the image to stream
        jpegDevice.process(pdfDocument.getPages().get_Item(pageCount), imageStream);

        // Close the stream
        imageStream.close();
        log.info("iteration {}, ASPOSE conversion process for image \"{}\" completed. Starting resizing flow.",
                pageCount, asposeResultFileName);
    }

@chandrakant.bagewadi,

What is AsposeConversionMode?

What is config??

Can I see the code of them?

So I can replicate behavior.

@chandrakant.bagewadi,

Because your snippet cannot be used for all those objects that are not included, I made a simplfied version of it and it works fine. Here is the input and the output:

Input / Output:
ConvertPdfToJpg_input.pdf (92.3 KB)
ConvertPdfToJpg_page1_output.jpg (84.3 KB)

Do you have the fonts used in the PDF installed in the machine that is doing the conversion?

If not that maybe be the cause.

Thanks Carlos,

To be more specific our customer raised the issue where Ariel ( Bold ) font in the PDF was replaced with just Ariel in the JPEG.

Our Config is - Aspose Conversion Mode = DPI and DPI Value = 120

Are you saying that these fonts should be installed on machine where we run conversion application ?

Please let me know.

@chandrakant.bagewadi,

The machine that is running the program must have the font installed. If by any chance the font is missing then the font get replaced.

But what you are telling me is that is changing a font from the same family. So it should be installed,

Also maybe here I am in the wrong, so correct me if I am. Are you talking to the same PDF file you gave me in the other post?

Because I reviewed it and there is no ArialBold font used in the document:

If it is a different PDF couldt please attach here too? so I could research with it, please.

it is different pdf, I am checking with few people before sharing it

Hi Carlos,

Please find the attached PDF for which we are facing issue where fonts are replaced.

Ariel Bold font title in Page#1 and Page#2 are replaced with normal Ariel font in converted images. ( Attached )

Thanks

Chandrakant

test_pdf_deck_22023.pdf (400 KB)

PDF font.jpg (436 KB)

@chandrakant.bagewadi,

I used adobe acrobat pro 2020. and the font of the section you are looking for is not even Arial. It is Calibri. Only Page 2 is on Arial

I would suggest you use acrobat reader to inspect a document instead of a web tool. They can be buggy sometimes.

Also, I run the following code:

private void Logic()
{
    Document doc = new Document($"{PartialPath}_input.pdf");
    
    foreach (var page in doc.Pages)
    {
        var jpegDevice = new JpegDevice(new Resolution(120));

        // Convert a particular page and save the image to stream
        jpegDevice.Process(page, $"{PartialPath}_page{page.Number}_output.jpg");
    }
}

I can see the font being bolded, compared to the rest of the words. The JPG file is on the left side, and on the right is Acrobat Reader.
Maybe if you increase the quality will be better.
If this is still not what you want, I can create a ticket for the dev team. Let me know, and I will do that.

Page one and Two
ConvertPdfToJpg_3_page1_output.jpg (171.8 KB)
ConvertPdfToJpg_3_page2_output.jpg (99.5 KB)

Thanks Carlos.

For Fonts, can you elaborate the steps - Where you told fonts should be available on the Server or machine where conversion application runs.

It may be working as our set-up is missing this step.

Ours is Dockized Micro-service and we are working for this set-up and test after that.

Thanks

Chandrakant

Hi Carlos,

Here is attaches Sample PDF for Image issue & Also converted image.

The issue is Gradient left side in the Page#1 of PDF is converted to Solid Black in the image.

zeitview_roofing_roughcut.pdf (12.3 MB)

image-20230301-183757.jpg (173 KB)

@chandrakant.bagewadi,

I see the issue.

I will try to replicate it locally to create a proper ticket for the dev team.

@chandrakant.bagewadi
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-53928

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Thanks @carlos.molina

This ticket you raised to DEV team is for the issue where Gradient left side in the Page#1 of PDF is converted to Solid Black in the image, The fix will be available in future Aspose versions Right ?

Just to update after we set-up font’s on our server, The font issue seems to be resolved.

Thanks
Chandrakant

@chandrakant.bagewadi,

Yes, the ticket is for the gradient issue upon conversion.

Also yes, the fix will be included in future versions of Aspose.Pdf. But keep in mind I am not part of the Dev team so I do not know when this will be fixed as is a separated team with their own sprints and scheduling. So when this will be fixed is out of y hands.

Regarding the font issue, great. Many people think that the fonts are required on the clients machine but they are needed in the Rendering machine. The one that actually run the code and do the document creation.

Thanks @carlos.molina, I come to know that our company has Paid support from Aspose, So I will ask this ticket in Priority list,

You can add it

@chandrakant.bagewadi,

Sorry, but Paid support is a different team I do not contact directly, only clients. You do not have to create a ticket but tell them the ticket number I started, which is PDFNET-53928.

Please, be sure to refer to this ticket when you explain to them that you need paid support. So there are no duplicated issues.

Thanks @carlos.molina, Will do

1 Like

@chandrakant.bagewadi,

To give you feedback, it seems the issue was found and fixed. And the fix will be released with version 23.4.