How to set Manually the Document Conformance Level for PDF A3

Stimulsoft Reports.JS discussion
Post Reply
yurilima
Posts: 13
Joined: Wed Oct 11, 2023 10:11 am

How to set Manually the Document Conformance Level for PDF A3

Post by yurilima »

At the moment that is how i am trying to set the PDF A3 Complice mode, however i am still getting errors. I attached a pic where it shows the error from a validator website. https://avepdf.com/pdfa-validation

Could you please tell me where am doing the mistake ?

Code: Select all

async getReportPDFAsBuffer(report: StimulsoftType.Report.StiReport): Promise<number[]> {

        // Create an PDF settings instance. You can change export settings.
        var settings = new Stimulsoft.Report.Export.StiPdfExportSettings();
        // 1.
        // settings.imageResolutionMode = Stimulsoft.Report.Export.StiImageResolutionMode.Exactly;
        // 2.
        // settings.imageResolution = 100;
        // 3.
        settings.imageCompressionMethod = Stimulsoft.Report.Export.StiPdfImageCompressionMethod.Flate;
        // 4.
        settings.allowEditable = Stimulsoft.Report.Export.StiPdfAllowEditable.No;
        // 5.
        settings.embeddedFonts = true;
        // 6.
        settings.pdfComplianceMode = Stimulsoft.Report.Export.StiPdfComplianceMode.A3;

        settings.pdfACompliance = true;
        settings.compressed = true;
        // settings.standardPdfFonts = true;

        // settings.autoPrintMode = Stimulsoft.Report.Export.StiPdfAutoPrintMode.None;


        settings.ZUGFeRDComplianceMode = Stimulsoft.Report.Export.StiPdfZUGFeRDComplianceMode.V2;
        // settings.ZUGFeRDConformanceLevel = 'PDF/A-3';

        // report.getFonts().forEach((font: StimulsoftType.System.Drawing.Font) => {
        //     console.log("Font", font.name);
        // });

        // Create an PDF service instance.
        var service = new Stimulsoft.Report.Export.StiPdfExportService();

        // Create a MemoryStream object.
        var stream = new Stimulsoft.System.IO.MemoryStream();

        // return new Promise((resolve, reject) => {
        //     report.exportDocumentAsync((event) => {
        //         console.log("Exporting", event);
        //         resolve(event);
        //     }, Stimulsoft.Report.StiExportFormat.Pdf, service, settings);
        // });

        // return new Promise((resolve, reject) => {
        //     report.exportDocument(Stimulsoft.Report.StiExportFormat.Pdf, service, settings, (event) => {
        //         console.log("Exporting", event);
        //         resolve(event);
        //     });
        // });



        // return new Promise((resolve, reject) => {
        //     service.exportPdf(report, stream, settings);
        //     const data = stream.toArray();
        //     resolve(data);
        // });

        // return new Promise((resolve, reject) => {
        //     service.exportTo2(report, stream, settings).then(() => {
        //         const data = stream.toArray();
        //         resolve(data);
        //     });
        // });

        // Export to PDF asynchronously
        return new Promise((resolve, reject) => {
            service.exportToAsync(async () => {
                const data = stream.toArray();
                resolve(data);

            }, report, stream, settings);
        });

    }
Attachments
Screenshot 2024-04-26 at 15.59.57.png
Screenshot 2024-04-26 at 15.59.57.png (47.1 KiB) Viewed 543 times
Lech Kulikowski
Posts: 6417
Joined: Tue Mar 20, 2018 5:34 am

Re: How to set Manually the Document Conformance Level for PDF A3

Post by Lech Kulikowski »

Hello,

Can't see what the problem is from the screenshot.
At first glance - most often the problem in JS is with fonts, you need to have all the necessary fonts loaded in StiFontCollection.
If it doesn't help, send an example report and the resulting pdf file for analysis.

Thank you.
yurilima
Posts: 13
Joined: Wed Oct 11, 2023 10:11 am

Re: How to set Manually the Document Conformance Level for PDF A3

Post by yurilima »

Hi, sorry for my delay to reply.
Actually i was giving priority to solve different issue which now seems to be solved.|

Ok, lets break it down.

I have the code as a picture also in case to see much clear:
Basically i use that to set the settings before call the pdf to be printed.
However, i always says after a validation that the conformance level is missing.
Do you have any clue what am i missing to be set in settings?

Code: Select all

	/**
     * @description Set the PDF settings for the report mainly used for pdf A3 Compliance.
     * @param report Stimulsoft.Report.StiReport Optional - Null by default
     */
    setPdfDefaultSettings(report: StimulsoftType.Report.StiReport = null): void {

        // this.settings.imageResolutionMode = Stimulsoft.Report.Export.StiImageResolutionMode.Auto;

        // settings.imageResolution = 100;

        this.settings.imageCompressionMethod = Stimulsoft.Report.Export.StiPdfImageCompressionMethod.Indexed;

        this.settings.allowEditable = Stimulsoft.Report.Export.StiPdfAllowEditable.Yes;

        this.settings.embeddedFonts = true;

        this.settings.pdfComplianceMode = Stimulsoft.Report.Export.StiPdfComplianceMode.A3;

        this.settings.pdfACompliance = true;
        this.settings.compressed = true;
        // settings.standardPdfFonts = true;

        this.settings.ZUGFeRDComplianceMode = Stimulsoft.Report.Export.StiPdfZUGFeRDComplianceMode.V2_1;
        this.settings.ZUGFeRDConformanceLevel = 'Extended'; // Basic, Comfort, Extended.
    }
Attachments
Validation-Message
Validation-Message
Screenshot 2024-05-30 at 14.17.10.png (115.09 KiB) Viewed 106 times
Set-Pdf-Settings
Set-Pdf-Settings
Screenshot 2024-05-30 at 14.22.15.png (238.94 KiB) Viewed 106 times
Save-Report-To-PDF
Save-Report-To-PDF
Screenshot 2024-05-30 at 14.25.40.png (174.04 KiB) Viewed 106 times
Post Reply