Converting Word to PDF issue

Hello,
we are about to extend or Word.NET license but our Word document conversion does not work fine.
Basically the issues is that checkbox content controls are displayed displayed as dots not checkboxes.
I attached images to demo of the porblem.

Not sure if that is trial version limitation or…since when we open processed with Aspose Word document and save from Word app as PDF no issues?

//C# code to convert to PDF

    public byte[] ExportWordToPDF(byte[] documentContBytes, string watermark, CancellationToken cancellationToken)
    {
        Stream stream = new MemoryStream();
        stream.Write(documentContBytes, 0, documentContBytes.Length);
        stream.Position = 0;
        Document doc = new Document(stream);

        if (!String.IsNullOrEmpty(watermark))
            doc = InsertWatermark(watermark, doc);

        //Instantiate the PdfSaveOptions class object before converting the Docx to PDF
        var pdfOptions = new PdfSaveOptions
        {
            //pdfOptions.PageSet = new PageSet(1, 3);
            //pdfOptions.PageMode = PdfPageMode.FullScreen;
            Compliance = PdfCompliance.Pdf17,
        };

        MemoryStream pdfStream = new MemoryStream();
        doc.Save(pdfStream, pdfOptions);

        // Return PDF as a byte array
        byte[] docBytes = pdfStream.ToArray();
        return docBytes;
    }

@milazora

It seems you are experiencing an issue where checkbox content controls in your Word document are being converted to dots instead of checkboxes when using Aspose.Words to convert to PDF. This can be frustrating, especially since the document appears correctly when saved as a PDF directly from the Word application.

Here are a few suggestions to troubleshoot and potentially resolve this issue:

  1. Check Aspose.Words Version: Ensure that you are using the latest version of Aspose.Words. Sometimes, issues like these are resolved in newer releases, so updating might help.

  2. PDF Save Options: You are currently using PdfCompliance.Pdf17 in your PdfSaveOptions. You might want to experiment with different compliance settings, such as PdfCompliance.Pdf15 or PdfCompliance.PdfA1b, to see if that affects how the checkboxes are rendered.

  3. Content Control Settings: Verify if there are any specific settings or properties related to content controls in your Word document that might affect their rendering during conversion. Sometimes, certain properties may not be fully supported in the conversion process.

  4. Testing with Different Documents: Try converting a different Word document that contains checkbox content controls to see if the issue persists. This can help determine if the problem is document-specific.

  5. Trial Version Limitations: If you are using a trial version of Aspose.Words, it is worth checking the documentation or contacting support to confirm if there are any limitations regarding the conversion of specific content types.

  6. Sample Code: Your current implementation looks good, but ensure that the document you are loading is correctly formatted and contains the expected content controls. Here’s a simplified version of your code for reference:

    public byte[] ExportWordToPDF(byte[] documentContBytes, string watermark, CancellationToken cancellationToken)
    {
        using (MemoryStream stream = new MemoryStream(documentContBytes))
        {
            Document doc = new Document(stream);
            if (!string.IsNullOrEmpty(watermark))
                doc = InsertWatermark(watermark, doc);
    
            var pdfOptions = new PdfSaveOptions
            {
                Compliance = PdfCompliance.Pdf17,
            };
    
            using (MemoryStream pdfStream = new MemoryStream())
            {
                doc.Save(pdfStream, pdfOptions);
                return pdfStream.ToArray();
            }
        }
    }
    

If the issue persists after trying these suggestions, consider reaching out to Aspose support with detailed information about your document and the specific behavior you are encountering. They may provide more targeted assistance.

Feel free to share any additional details or screenshots if you need further help!

Sources:
[1]: Base conversions.cs

issues.png (54.9 KB)

@milazora Most likely the problem occurs because the fonts used in your input document are not available on the machine where document is converted to PDF. If Aspose.Words cannot find the font used in the document, the font is substituted. This might lead into fonts mismatch and document layout differences due to the different fonts metrics. You can implement IWarningCallback to get notifications when font substitution is performed.
Please see our documentation to learn where Aspose.Words looks for fonts:
https://docs.aspose.com/words/net/specifying-truetype-fonts-location/

If after providing the required fonts the problem still persists, please attach your problematic input and output documents here for testing. We will check the issue and provide you more information.

@milazora Thank you for additional information. The problem is not reproducible on my side. Here are PDF documents produced on my side.
Aspose.Words: out.pdf (112.9 KB)
MS Word: ms.pdf (196.3 KB)

That is great but what version of your control and what code you are using to perform PDF conversion with Aspose.Words?
What else could cause this problem, if fonts location could be issue how to set fonts location before PDF conversion call?

Thanks.

@milazora Please see our documentation to learn where Aspose.Words looks for fonts and how to specify fonts location:
https://docs.aspose.com/words/net/specifying-truetype-fonts-location/

Hello Alexsey,

no warning I got after during pdf conversion. Still the same problems: some text formatting and some checkbox converted to bullets.

I noticed different temp license notice in your and mine version…attached image.

@milazora Most likely you are using an older version of Aspose.Words. Could you please attach the output PDF produced on your side?

@milazora The problem is with fonts. To render cakeboxes in your document MS Gothic font is used. Most likely it is not available in the environment where the document is rendered. Please try installing in and check conversion again.

Hello Alexey,
I installed that font and attach the list of fonts on my VM where I ran conversion.
Still problem with PDF conversion. :frowning:
This is big problem for us since we are getting extended license soon.
Fonts5109.pdf (68.0 KB)

@milazora Does IWarningCallback show any warnings about font substitution? Could you please save the output document as XPS (using Aspose.Words) and attach the result here for our reference?

@milazora Thank you for addition information. It is strange. Because Times New Roman font is used in your document to render bullets. Do you perform any pre-processing of the document before conversion?

Yes we do process like replace text and set checkbox controls.
Attached pdf converted from non-processed word doc and better still some issues.

Since your out.pdf converted with Aspose code from our word doc with no issue, it seems some environments problem in our case…beside table warnings no others warnings (like fonts).
Again when manually convert final fully processed word doc on my laptop (not VM where is Aspose) with FoxIt all good.
Not easy to troubleshoot here.

BTW…
Please can we get private support channel (with emails ) since I cannot share a lot document publicly?
I deleted some post with attached documents

@milazora Could you please create a simple console application that will allow us to reproduce the problem on our side? We will check the issue and provide you more information.

Hello Alexey,
thank you for your help…I resolved the problem by using for checkboxes
Checked and Unchecked symbols
this font:
Wingdings 2

@milazora It is perfect that you managed to resolve the problem. Please feel free to ask in case of any other issues, we are always glad to help you.

I managed to figure it out with your great support and lead. :+1:
Thank you again!

1 Like