Docx to PDF conversion: Bullet lists lost

0 Answers 116 Views
PdfProcessing WordsProcessing
Carmine
Top achievements
Rank 1
Carmine asked on 12 Oct 2021, 03:58 PM

Hello,

i'm trying to convert some docx to PDF. The resulting document looks quite similar to the original, however i have 2 main issues:

  • Bullet lists are not present on the exported document
  • Bold text is never present in the exported document
  • The exported pdf file doesn't seem to be a valid PDF/A-3U one checking with some online validator

 

i've attached a very simple example.

Here is the code i'm using to generate the pdf:


public byte[] Convert()
{
    //to support fonts
    Telerik.Windows.Documents.Extensibility.FontsProviderBase fontsProvider = new FontsProvider();
    Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.FontsProvider = fontsProvider;

    //to support PNG's
    Telerik.Windows.Documents.Extensibility.JpegImageConverterBase jpegImageConverter = new Telerik.Documents.ImageUtils.JpegImageConverter();
    Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.JpegImageConverter = jpegImageConverter;

    var importProvider = new DocxFormatProvider();
    byte[] templateData = GetTemplateData(); 
    var template = importProvider.Import(templateData);

    var pdfProvider = new PdfFormatProvider();
    PdfExportSettings settings = new();
    settings.ComplianceLevel = PdfComplianceLevel.PdfA3U;
    pdfProvider.ExportSettings = settings;
    var pdfBytes = pdfProvider.Export(template);
    return pdfBytes;
}

//... end class

public class FontsProvider : Telerik.Windows.Documents.Extensibility.FontsProviderBase
    {
        public override byte[] GetFontData(FontProperties fontProperties)
        {
            string fontFileName = fontProperties.FontFamilyName + ".ttf";
            string fontFolder = Environment.GetFolderPath(Environment.SpecialFolder.Fonts);
            string targetPath = Path.Combine(fontFolder, fontFileName);

            DirectoryInfo directory = new DirectoryInfo(fontFolder);
            FileInfo[] fontFiles = directory.GetFiles("*.ttf");
            if (fontFiles.Any(s => s.Name.Equals(fontFileName, StringComparison.InvariantCultureIgnoreCase)))
            {
                using (FileStream fileStream = File.OpenRead(targetPath))
                {
                    using (MemoryStream memoryStream = new MemoryStream())
                    {
                        fileStream.CopyTo(memoryStream);
                        return memoryStream.ToArray();
                    }
                }
            }

            return null;
        }
    }

 

am i missing something?

Thanks in advance for your help!

Peshito
Telerik team
commented on 15 Oct 2021, 07:25 AM

Hello Carmine, 

Thank you for your detailed description of the issue you are facing. I used the source and was able to properly export the document. The exported PDF looked like the source DOCX with the bullets. Attached is the output I got. 

Could you try using the latest version of the Document Processing Library and try again. If the issue still persists, please attach a sample runnable project reproducing it?

As for the PDF/A-3U compliance, please take a look at our help article How to Comply with PDF/A Standard

Regards,

Peshito

Carmine
Top achievements
Rank 1
commented on 15 Oct 2021, 09:43 AM

Hi Peshito,

 

thanks for your reply.

i was using the version 2021.1.119 and when i updated to 2021.3.909 most of the issues were solved, meaning that the bullet lists are now appearing. Regarding the PDF/A issue, i validated the docs against adobe validator and they are fine, sorry for that.

However, there is still an issue i have, and it is also replicable from your live demo at https://demos.telerik.com/aspnet-ajax/wordsprocessing/exporttopdf/defaultcs.aspx?show-source=true

Basically i'm using the same code of the demo as you can see, but nested numbered lists are not showing properly.

Could you give me some advice on that?

thanks

Peshito
Telerik team
commented on 18 Oct 2021, 09:27 AM

Hello Carmine,

I am glad the previous issue is solved after the upgrade.

As for the latest one with the nested numbering, I confirm this is an issue. There is a related public feedback item that you could subscribe to and get notified when the status of the item gets updated - WordsProcessing: List indent is not correct when exported to PDF. I am afraid I cannot provide a valid workaround at the moment.

Best Regards,

Peshito

 

Carmine
Top achievements
Rank 1
commented on 18 Oct 2021, 10:11 AM

ok, thank you very much for your support and your explainations Peshito!

 

Regards,

Carmine

Peshito
Telerik team
commented on 19 Oct 2021, 07:23 AM

You are very welcome, Carmine!

Best Regards,

Peshito

No answers yet. Maybe you can help?

Tags
PdfProcessing WordsProcessing
Asked by
Carmine
Top achievements
Rank 1
Share this question
or