Converting Word to PDF/A

Hi, I am loosing the format of the word document while converting to a PDF/A.

Below is sample code that i am using.

public static byte[] method()
{
    ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
    try
    {
        Document doc = new Document(new ByteArrayInputStream(inputByteArray));
        doc.save(byteStream, getSaveOptions());
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }

    byteStream.toByteArray();
}

private static PdfSaveOptions getSaveOptions()
{
    PdfSaveOptions saveOptions = new PdfSaveOptions();
    saveOptions.setCompliance(PdfCompliance.PDF_A_1_B);
    saveOptions.setSaveFormat(SaveFormat.PDF);
    return saveOptions;
}

Attached sample word document.

Hi Sherry,

Thanks for your inquiry. I have tested the scenario using latest version of Aspose.Words for Java 14.10.0 and have not found the shared issue. Please use Aspose.Words for Java 14.10.0. I have attached the output document with this post for your kind reference.

Hi, When I tried with 14.10.0 version, I was able to get the same output that you have in output.pdf.
Is there any way to retain the original word format in the PDF. Without the header and page number and having exact lines and characters in the original word document? Please let me know.

Thanks

Hi Sherry,

Thanks for your inquiry. Yes, you can convert Word document to Pdf without header/footers using Aspose.Words. Please use following code example to achieve your requirements. Hope this helps you. Please let us know if you have any more queries.

Document doc = new Document(MyDir + "in.docx");
for (Section section : doc.getSections())
{
     section.getHeadersFooters().clear();
}
doc.save(MyDir + "Out.pdf");