Aspose.Pdf v17.9+ IsTruetypeFontMapCached | TruetypeFontMapPath | Conformance | Linearized

I’m trying to port the following code to 18+ aspose.Pdf version.

I know the Generator is not there anymore. but can’t seem to find a way to convert the following.
Could help me the following code?

                        Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf(outStream); 

                        pdf.IsTruetypeFontMapCached = true;
                        pdf.TruetypeFontMapPath = Path.GetTempPath();
                        if (PDFA)
                        {
                            pdf.Conformance = Aspose.Pdf.Generator.PdfConformance.PdfA1B;
                        }
                        else
                        {
                            pdf.Conformance = Aspose.Pdf.Generator.PdfConformance.None;
                        }

                        if (Linearized)
                        {
                            pdf.Linearized = true;
                        }
                        else
                        {
                            pdf.Linearized = false;
                        }

                        // Produce the PDF file.
                        string outputFilePath = string.Format("{0}_page{1:00000}.pdf", outFile, iPage);
                        using (FileStream outputStream = new FileStream(outputFilePath, FileMode.Create))
                        {
                            outStream.WriteTo(outputStream);
                            pdf.Close();
                            outputStream.Close();
                        }

                        _outputFiles.Add(outputFilePath); // Add reference
                    }

@Luk_De_Reu

Thank you for contacting support.

When using legacy Aspose.Pdf.Generator, the Aspose.Pdf.TrueTypeFontMap.xml was used to gather information regarding fonts installed over system. So when pdf.IsTruetypeFontMapCached = true; is called, a file named Aspose.Pdf.TruetypeFontMap.xml was created over the path specified against pdf.TruetypeFontMapPath.

Now concerning to new DOM approach, there is no need to have such file as the API can automatically locate the fonts installed over system.

Moreover, Document class exposes IsLinearized property and Validate method which may be used as per your requirements.

Document document = new Document(dataDir + "Test.pdf");
document.Validate(dataDir + "validation-result-A1A.xml", PdfFormat.PDF_A_1A);
bool linearize = document.IsLinearized;

We hope this will be helpful. Please feel free to contact us if you need any further assistance.