We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Embed Fonts Hide Comments & Show Bookmarks in PDF Outline during DOCX to PDF Conversion using C# .NET

When we are creating pdf with OutlineOptions we get corrupted pdfs for some programs. Same code without OutlineOptions works fine.

For example http://checkers.eiii.eu/en/pdfcheck/ reports it as broken.

files.zip (144.5 KB)

public MemoryStream ToPdf(Stream documentStream, string basePath)
{
    var document = new Document(documentStream);
    document.LayoutOptions.ShowComments = false;
    var pdfStream = new MemoryStream();
    document.Save(pdfStream, GetMoreAccessibilityFriendlyOptions());

    return pdfStream;
}

private PdfSaveOptions GetMoreAccessibilityFriendlyOptions()
{
    var options = new PdfSaveOptions()
    {
        Compliance = PdfCompliance.PdfA1a,
        ExportDocumentStructure = true,
        FontEmbeddingMode = PdfFontEmbeddingMode.EmbedAll,

        UseCoreFonts = false,
        HeaderFooterBookmarksExportMode = HeaderFooterBookmarksExportMode.All,

        DisplayDocTitle = true
    };
    options.OutlineOptions.ExpandedOutlineLevels = 2;
    options.OutlineOptions.HeadingsOutlineLevels = 2;
    options.OutlineOptions.DefaultBookmarksOutlineLevel = 2;
    options.OutlineOptions.CreateMissingOutlineLevels = true;
    return options;
}

@lars.olsson,

For the sake of any correction, we have logged this problem in our issue tracking system with ID WORDSNET-20846. We will further look into the details of this problem and will keep you updated on the status of linked issue. We apologize for your inconvenience.

@lars.olsson,

During further investigation of WORDSNET-20846, we have found that the specified online checker reports not an error in Aspose.Words output but an error in itself. Here is the recent message:

An error occurred:
The page could not be downloaded. This type of document can not be checked by the eAccessibility Checker.
Message: Unguarded error => [KeyError : '/Pg' ] <=. Please send feedback to developers.

So, it may be or may not be an error in Aspose.Words PDF output. Also Acrobat Preflight, 3-HEIGHTS™ PDF VALIDATOR and Aspose.PDF validator do not show errors in Aspose.Wods PDF output.

We don’t see any problems in Aspose.Wods PDF export, so suggest you to contact the checker's developer to get more information about the problem in Aspose.Words output, or to confirm it is a bug in the checker itself.