Flatten changes PDF-Format

Hi,

in my use case, I have to load a PDF/a (PDF-a 2b) and flatten the fields. After flattening, the PDF format is changed to v_1_7. Is there a way that the format is not changed or do I have to do a conversion again?

using (var strmIn = new MemoryStream(pdfData))
{
    using (var inputDok = new Document(strmIn))
    {
        if (inputDok.Form.Count > 0)
        {
            inputDok.Flatten();

            using (var strmOut = new MemoryStream())
            {
                inputDok.Save(strmOut);
                return strmOut.ToArray();
            }
        }
    }
}

@Verus2020

Could you please share your input PDF and problematic output PDF here for testing? We will investigate the issue and provide you more information on it.

Hi,

here is an example:

49690_Sonstiges.pdf (1.9 MB)

@Verus2020

We suggest you please read following article to convert final output to PDF/A format.
Convert PDF to PDF/A formats

You can use following code snippet to get the desired output.

using (var strmIn = new MemoryStream(File.ReadAllBytes(MyDir + "49690_Sonstiges.pdf")))
{
    using (var inputDok = new Document(strmIn))
    {
        if (inputDok.Form.Count > 0)
        {
            inputDok.Flatten();

            using (var strmOut = new MemoryStream())
            {
                inputDok.Convert(dataDir + "log.xml", PdfFormat.PDF_A_1B, ConvertErrorAction.Delete); 
                inputDok.Save(MyDir + "output.pdf");
            }
        }
    }
}

Ok, so I need to convert the document again.

@Verus2020

We have logged this problem in our issue tracking system as PDFJAVA-42342. We will inform you once there is an update available on it.