Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Mon May 24, 2021 2:22 pm

Hi,

if i generate a pdf file with
Code: Select all
PdfVersion.Version1_5
or above and conformance
Code: Select all
PDFConformanceLevel.Pdf_A1B
the files is generated correctly,
but if i do pdf/a verification (using for example bfo.com or freepdfonline.com) it give me an error "CompressedXRef is set, but shouldn't be".

How to solve?

Thanks

arthurinformatica
 
Posts: 15
Joined: Thu Apr 15, 2021 12:47 pm

Tue May 25, 2021 7:52 am

Hello,

Thank you for your inquiry.
I used the latest Spire.PDF (Spire.PDF Pack(Hot Fix) Version:7.5.7) to set Version1_5 and PDFA1B conformance, but did not replicate your issue. If you were not using the latest version, we recommend you give it a try. If the problem still exists, please provide your input PDF (if any) and output PDF. You could attach them here or send to us via email (support@e-iceblue.com). Thanks in advance.

Sincerely,
Annika
E-iceblue support team
Last edited by Annika.Zhou on Tue May 25, 2021 9:46 am, edited 1 time in total.
User avatar

Annika.Zhou
 
Posts: 1648
Joined: Wed Apr 07, 2021 2:50 am

Tue May 25, 2021 9:39 am

I have updated to the latest version on Spire.PDF but it did not solve the issue.

i can reply the issue with the code below, if i set PdfVersion1_5 or above, checking the pdf on bfo.com/blog/2017/11/08/verify_pdfa_online/ it return "CompressedXRef is set, but shouldn't be", if instead i set PdfVersion1_4 or below, it check correctly.



Code: Select all
var pdfDoc = new Spire.Pdf.PdfDocument(Spire.Pdf.PdfConformanceLevel.PDF_A1B);
pdfDoc.FileInfo.Version = Spire.Pdf.PdfVersion.Version1_5;
pdfDoc.CompressionLevel = Spire.Pdf.PdfCompressionLevel.Best;
pdfDoc.DocumentInformation.Author = "Arthur Informatica s.r.l.";

var pdfPage = pdfDoc.Pages.Add(Spire.Pdf.PdfPageSize.A4, new Spire.Pdf.Graphics.PdfMargins(0), Spire.Pdf.PdfPageRotateAngle.RotateAngle0, Spire.Pdf.PdfPageOrientation.Portrait);

var oldCanvas = pdfPage.Canvas.Save();

var left = 91.6f;
var top = 661.654968f;
var height = 8.4f;
var width = 241.2f;
   
var font = new System.Drawing.Font("Arial", 5, System.Drawing.FontStyle.Regular);
var pdfFont = new Spire.Pdf.Graphics.PdfTrueTypeFont(font, true);
var pdfBrush = new Spire.Pdf.Graphics.PdfSolidBrush(new Spire.Pdf.Graphics.PdfRGBColor(System.Drawing.Color.Black));

var stringFormat = new Spire.Pdf.Graphics.PdfStringFormat(Spire.Pdf.Graphics.PdfTextAlignment.Left, Spire.Pdf.Graphics.PdfVerticalAlignment.Top);
pdfPage.Canvas.TranslateTransform(left, top);
pdfPage.Canvas.RotateTransform(obj.Angle);
var rect = new System.Drawing.RectangleF(0, 0, width, height);

pdfPage.Canvas.DrawString("Test 1 2 3", pdfFont, pdfBrush, rect, stringFormat);

pdfPage.Canvas.Restore(oldCanvas);

pdfDoc.SaveToFile(@"C:\temp\test.pdf");
pdfDoc.Close();

arthurinformatica
 
Posts: 15
Joined: Thu Apr 15, 2021 12:47 pm

Tue May 25, 2021 11:05 am

Hello,

Thank you for your feedback.
We provide a new interface PdfStandardsConverter to convert to PDFA1B. I have verified the generated PDF on the website you provided, and there is no problem. Please use the following method to have a try.
Code: Select all
 
            var pdfDoc = new PdfDocument();
            pdfDoc.FileInfo.Version = PdfVersion.Version1_5;         
           
            pdfDoc.CompressionLevel = PdfCompressionLevel.Best;
            pdfDoc.DocumentInformation.Author = "Arthur Informatica s.r.l.";

            var pdfPage = pdfDoc.Pages.Add(PdfPageSize.A4, new PdfMargins(0), PdfPageRotateAngle.RotateAngle0, PdfPageOrientation.Portrait);

            var oldCanvas = pdfPage.Canvas.Save();

            var left = 91.6f;
            var top = 661.654968f;
            var height = 8.4f;
            var width = 241.2f;

            var font = new Font("Arial", 5, FontStyle.Regular);
            var pdfFont = new PdfTrueTypeFont(font, true);
            var pdfBrush = new PdfSolidBrush(new PdfRGBColor(Color.Black));

            var stringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
            pdfPage.Canvas.TranslateTransform(left, top);
            pdfPage.Canvas.RotateTransform(2f);
           
            var rect = new RectangleF(0, 0, width, height);

            pdfPage.Canvas.DrawString("Test 1 2 3", pdfFont, pdfBrush, rect, stringFormat);

            pdfPage.Canvas.Restore(oldCanvas);
            string file = "test.pdf";
            pdfDoc.SaveToFile(file);

            PdfStandardsConverter converter = new PdfStandardsConverter(file);                     
            string output = "test_out.pdf";
            converter.ToPdfA1B(output);
         
            pdfDoc.Close();


Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1648
Joined: Wed Apr 07, 2021 2:50 am

Fri May 28, 2021 8:57 am

Hi, i tried your sample and seem work, but if i set pdfDoc.FileInfo.Version = PdfVersion.Version1_6 then convert to PDFA1B, the output pdf version result 1.5, why?

Another issue using PdfStandardsConverter class is who it require a file in input, and does not accept a PDFDocument object, so creating a pdf require 2 step saving the file to disk. It would be better to manager PDFA conversion with a method in the class PDFDocument to optimize the processing performance.

arthurinformatica
 
Posts: 15
Joined: Thu Apr 15, 2021 12:47 pm

Fri May 28, 2021 11:08 am

Hello,

Below are my answers to your questions.
1) I have noticed that the version 1.6 became 1.5 after converting to PDFA1B, this issue has been logged into our Bug tracking system with the ticket number SPIREPDF-4338. Our development team will investigate and fix it. Once it is resolved, I will inform you. Sorry for the inconvenience caused.

2) Our Spire.PDF supports saving to stream, and the PdfStandardsConverter provides overload to receive stream. Please refer to the code below.
Code: Select all
             
            MemoryStream memoryStream = new MemoryStream();
            pdfDoc.SaveToStream(memoryStream,FileFormat.PDF);

            PdfStandardsConverter converter = new PdfStandardsConverter(memoryStream);
            string output = "result.pdf";
            converter.ToPdfA1B(output);

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1648
Joined: Wed Apr 07, 2021 2:50 am

Mon May 31, 2021 1:08 pm

Hi, i would like to report another issue related to PdfStandardsConverter class.

Converting to X1A2001 format it generate an invalid pdf.

You can reply the issue with the code posted above, call ToPdfX1A2001 method instead of ToPdfA1B.

arthurinformatica
 
Posts: 15
Joined: Thu Apr 15, 2021 12:47 pm

Tue Jun 01, 2021 3:00 am

Hello,

Thank you for your inquiry.
I tested your case to convert to X1A2001 format, but did not find the invalid Pdf issue. The generated PDF is successfully verified on the website (bfo.com/blog/2017/11/08/verify_pdfa_online/). Please see the following screenshot. Also I attached my output file for your reference.

Sincerely,
Annika
E-iceblue support team

screenshot.png

output.zip
User avatar

Annika.Zhou
 
Posts: 1648
Joined: Wed Apr 07, 2021 2:50 am

Wed Jun 02, 2021 10:58 am

Hi,

convert to X1A2001 issue:

using this code to create a pdf and convert to X1A2001 i obtain an invalid pdf - it can't be opened - (see attachment test.pdf and test_out.pdf):

Code: Select all
var pdfDoc = new Spire.Pdf.PdfDocument();
pdfDoc.FileInfo.Version = Spire.Pdf.PdfVersion.Version1_5;

pdfDoc.CompressionLevel = Spire.Pdf.PdfCompressionLevel.Best;
pdfDoc.DocumentInformation.Author = "Arthur Informatica s.r.l.";

var pdfPage = pdfDoc.Pages.Add(Spire.Pdf.PdfPageSize.A4, new Spire.Pdf.Graphics.PdfMargins(0), Spire.Pdf.PdfPageRotateAngle.RotateAngle0, Spire.Pdf.PdfPageOrientation.Portrait);

var oldCanvas = pdfPage.Canvas.Save();

var left = 91.6f;
var top = 661.654968f;
var height = 8.4f;
var width = 241.2f;

var font = new System.Drawing.Font("Arial", 5, System.Drawing.FontStyle.Regular);
var pdfFont = new Spire.Pdf.Graphics.PdfTrueTypeFont(font, true);
var pdfBrush = new Spire.Pdf.Graphics.PdfSolidBrush(new Spire.Pdf.Graphics.PdfRGBColor(System.Drawing.Color.Black));

var stringFormat = new Spire.Pdf.Graphics.PdfStringFormat(Spire.Pdf.Graphics.PdfTextAlignment.Left, Spire.Pdf.Graphics.PdfVerticalAlignment.Top);
pdfPage.Canvas.TranslateTransform(left, top);
pdfPage.Canvas.RotateTransform(2f);

var rect = new System.Drawing.RectangleF(0, 0, width, height);

pdfPage.Canvas.DrawString("Test 1 2 3", pdfFont, pdfBrush, rect, stringFormat);

pdfPage.Canvas.Restore(oldCanvas);
string file = @"c:\temp\test.pdf";
pdfDoc.SaveToFile(file);
pdfDoc.Close();

PdfStandardsConverter converter = new PdfStandardsConverter(file);
string output = @"c:\temp\test_out.pdf";
converter.ToPdfX1A2001(output);


convert to PDF1A issue:

using this code to convert a pdf to PDF1A i obtain a pdf without logo image and with some black lines added around some fields (see attachment NoPdfA.pdf and PdfA.pdf, for example the first page, the 2 logo images are missing, black lines are added around the white background of the word "CONTE"):

Code: Select all
var converter = new PdfStandardsConverter("NoPdfA.pdf");
converter.ToPdfA1B("PdfA.pdf");

arthurinformatica
 
Posts: 15
Joined: Thu Apr 15, 2021 12:47 pm

Thu Jun 03, 2021 9:04 am

Hello,

Thank you for your feedback.
1) I used the latest version of Spire.PDF (Spire.PDF Pack (Hot Fix) Version: 7.5.7) to test your case, but still did not reproduce your problem on my side. The generated X1A2001 file has no problem when opening. Here I uploaded my testing demo, please have a check.
https://www.e-iceblue.com/downloads/demo/25605.zip

2) I reproduced the missing images and black lines issues, the issues have beed logged into our Bug tracking system with the ticket number SPIREDF-4352. Our development team will investigate and fix them. Once there is any good news, I will inform you. Sorry for the inconvenience caused.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1648
Joined: Wed Apr 07, 2021 2:50 am

Fri Jun 04, 2021 9:16 am

Hi,

i use the same version of Spire.Pdf, i found who issue 1) is related to acrobat reader,

If i open the pdf in chrome it show correctly, but if i open in acrobat reader (Adobe Acrobat Reader DC 2021.001.20155) it show the error attached (AcrobatReaderError.png) and the page show empty.

arthurinformatica
 
Posts: 15
Joined: Thu Apr 15, 2021 12:47 pm

Fri Jun 04, 2021 11:12 am

Hello,

Thank you for your feedback.
I noticed that the test_out.pdf you provided can be opened in browser but not in Adobe. However, I was unable to reproduce your issue on my side. Did you test my demo? How is the result?
To help us further investigate your issue, please provide the following information. Thanks in advance.
1) Your test environment such as OS info (E.g. Windows7, 64bit) and region setting (E.g. China, Chinese).
2) Your application type such as Console app (.NET Framework 4.5).

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1648
Joined: Wed Apr 07, 2021 2:50 am

Fri Jun 04, 2021 11:56 am

I can reply the issue with your demo, so i think it could be a machine related issue.

My os version is Windows 10 Pro x64 (ver. 10.0.18362) with italian language.

I use an ASP.NET MVC application, but i replied the issue in your sample project (.net framework 4.7.2 console app).

arthurinformatica
 
Posts: 15
Joined: Thu Apr 15, 2021 12:47 pm

Mon Jun 07, 2021 10:54 am

Hello,

Sorry for the late reply on the weekend.
I tested the case in the same environment as yours and did find the invalid PDF issue. This issue is caused by the culture info, to avoid it, please set the current culture as InvariantCulture. Sample code is shown as below.
Code: Select all
            CultureInfo cc = Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            var pdfDoc = new PdfDocument();
            pdfDoc.FileInfo.Version = PdfVersion.Version1_5;
            ...
            PdfStandardsConverter converter = new PdfStandardsConverter(file);
            string output = "test_out.pdf";
            converter.ToPdfX1A2001(output);
            Thread.CurrentThread.CurrentCulture = cc;

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1648
Joined: Wed Apr 07, 2021 2:50 am

Mon Jun 07, 2021 2:30 pm

Hi,
Thanks for your reply.

I tested the code setting InvariantCulture and the pdf is opened correctly from acrobat reader, but also in this case there are some black lines issues as for PDFA1B conversion.
see attachments (No_PDFX1A2001.pdf and PDFX1A2001.pdf) for example the black lines in the white background near the word "PAOLO".

arthurinformatica
 
Posts: 15
Joined: Thu Apr 15, 2021 12:47 pm

Return to Spire.PDF