PDF/A-1 ISO 19005-1:2005 How to? Topic is solved

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 425
Joined: Fri Dec 09, 2016 7:28 am
Contact:

PDF/A-1 ISO 19005-1:2005 How to?

Post by cutecode »

I create PDF with wxPdfDC and send it to a web service.
I get response error

Code: Select all

An XObject dictionary shall not contain the SMask key
DeviceRGB may be used only if the file has a PDF/A-1 OutputIntent that uses an RGB colour space
I'm not PDF-guru, what does it mean?

My file should use this format
------------------------------------------------------------------
Document management - Electronic document file format for long-term preservation - Part 1: Use of PDF 1.4 (PDF/A-1) https://www.iso.org/standard/38920.html
-----------------------------------------------------------------------------------------------
Thank you.

Code: Select all

    wxPrintData printData = *g_printData;
    printData.SetFilename(lpszFileName);

    wxPdfDC dc(printData);
    {
        wxLogNull h;
        wxPdfFontManager::GetFontManager()->RegisterSystemFonts();
    }

    dc.SetMapModeStyle(wxPDF_MAPMODESTYLE_STANDARD);
    dc.SetMapMode(wxMM_POINTS);

	BOOL bREzult = FALSE;

	short rows = GetPossibleRows();
	short cols = GetPossibleColumns();

	if (!rows || !cols)
		return FALSE;

	int nPages = PrinterChanged();
	if (!nPages)
		return FALSE;

    bool ok = dc.StartDoc(_("Printing ..."));
    if (!ok)
        return false;

	BOOL bUseDirectPrinting = m_bUseDirectPrinting;
	m_bUseDirectPrinting = 0;

	int xPPI = dc.GetPPI().x;
	int yPPI = dc.GetPPI().y;

	wxArchivePageParams* PageParams =  GetPageParams();

	int mmX = dc.GetSizeMM().x - (PageParams->m_nLeft + PageParams->m_nRight)/100.0;
//	int mmY = dc.GetSizeMM().y - (PageParams->m_nTop + PageParams->m_nBottom)/100.0;

	int logX = MulDiv(xPPI, mmX*100, SM_PER_INCH);
	double oldscale = m_SgridData.m_PageParams.m_nPacent;
    m_SgridData.m_PageParams.m_nPacent = 100;
	//физичекие точки
	int XpxlL = MulDiv(xPPI, PageParams->m_nLeft, SM_PER_INCH);
	int YpxlT = MulDiv(yPPI, PageParams->m_nTop, SM_PER_INCH);

	for (int nPage = 1; nPage <= nPages; nPage++)
	{
		dc.StartPage();

		short col, row;
		long lWidth, lHeight;
		if (!nnn(nPage, col, row, lWidth, lHeight))
			break;
		if (!lWidth || !lHeight)
			break;

		double pc = (double)logX / (double)lWidth;
		dc.SetUserScale(pc, pc);
		wxRect rec(0, 0, lWidth, lHeight);
		dc.SetDeviceOrigin(XpxlL, YpxlT);

		OnPrint(&dc, nPage, &rec);

		dc.EndPage();
		dc.SetUserScale(1, 1);
	}

    dc.EndDoc();

    delete PageParams;

	m_bUseDirectPrinting = bUseDirectPrinting;

    bREzult = true;
	m_SgridData.m_PageParams.m_nPacent = oldscale;

//q:
	return bREzult;
Attachments
application (1).pdf.zip
(195.04 KiB) Downloaded 185 times
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: PDF/A-1 ISO 19005-1:2005 How to?

Post by utelle »

cutecode wrote: Mon Nov 16, 2020 5:14 pm I create PDF with wxPdfDC and send it to a web service.
I get response error

Code: Select all

An XObject dictionary shall not contain the SMask key
DeviceRGB may be used only if the file has a PDF/A-1 OutputIntent that uses an RGB colour space
I'm not PDF-guru, what does it mean?
Although I'm the author of wxPdfDocument and know the PDF standard to a certain degree, I wouldn't call myself a PDF expert. Therefore I can only try to give some (hopefully helpful) hints, but can't provide a fully qualified explanation.
cutecode wrote: Mon Nov 16, 2020 5:14 pm My file should use this format
------------------------------------------------------------------
Document management - Electronic document file format for long-term preservation - Part 1: Use of PDF 1.4 (PDF/A-1) https://www.iso.org/standard/38920.html
-----------------------------------------------------------------------------------------------
I suppose that you ask the web service to check your PDF document for comformity to PDF/A-1. Unfortunately, I don't have access to the PDF/A standard document, so that I can't check all the details describing the restrictions for the PDF/A format. wxPdfDocument does not enforce conformity to a certain PDF standard. It is the user's responsibility to use only features supported by the selected standard.

What I know is that PDF/A comforming PDF documents must not use transparency features. However, your document uses 2 graphics/images with transparency, and this leads to the use of the SMask key mentioned in the error message.

Your code snippet doesn't show the actual drawing code. My guess is that the code contains calls to DrawBitmap with parameter useMask set to true. Set useMask to false, and check the resulting PDF document again. If you are lucky, this is already sufficient to achieve PDF/A-1 conformity.
User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 425
Joined: Fri Dec 09, 2016 7:28 am
Contact:

Re: PDF/A-1 ISO 19005-1:2005 How to?

Post by cutecode »

Hello, utelle!!!

Thank you for your help.

I removed all images from PDF, now I have this error

Code: Select all

DeviceRGB may be used only if the file has a PDF/A-1 OutputIntent that uses an RGB colour space
Absolute real value must be less than or equal to 32767.0
Attachments
1.pdf.zip
(47.79 KiB) Downloaded 163 times
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: PDF/A-1 ISO 19005-1:2005 How to?

Post by utelle »

cutecode wrote: Mon Nov 16, 2020 7:37 pm I removed all images from PDF, now I have this error

Code: Select all

DeviceRGB may be used only if the file has a PDF/A-1 OutputIntent that uses an RGB colour space
Absolute real value must be less than or equal to 32767.0
Unfortunately, wxPdfDocument does currently not support adding OutputIntent attributes. You could try to tweak wxPdfDocument by removing line 1030

Code: Select all

      Out("/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>");
from source file pdfkernel.cpp. This might eliminate the first error message.

I have no idea what's causing the second message about a real value.
User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 425
Joined: Fri Dec 09, 2016 7:28 am
Contact:

Re: PDF/A-1 ISO 19005-1:2005 How to?

Post by cutecode »

I rebuilded and reinstalled wxPDF

Code: Select all

    // TODO: not sure whether writing the group dictionary is necessary
 /*   if (m_PDFVersion > wxS("1.3"))
    {
      Out("/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>");
    }*/
The same result.

Code: Select all

Absolute real value must be less than or equal to 32767.0
DeviceRGB may be used only if the file has a PDF/A-1 OutputIntent that uses an RGB colour space
am totally frustrated.
Attachments
2.pdf.zip
(48 KiB) Downloaded 168 times
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: PDF/A-1 ISO 19005-1:2005 How to?

Post by utelle »

cutecode wrote: Mon Nov 16, 2020 9:50 pm I rebuilded and reinstalled wxPDF

The same result.

Code: Select all

Absolute real value must be less than or equal to 32767.0
DeviceRGB may be used only if the file has a PDF/A-1 OutputIntent that uses an RGB colour space
am totally frustrated.
I fully understand your frustration. However, the PDF file 2.pdf you attached still contains the transparency group attributes:

Code: Select all

/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>
That is, although you rebuilt wxPdfDocument, your application obviously still used the unmodified version to generate the file 2.pdf. Make sure your application is linked to the modified wxPdfDocument library or loads the modified wxPdfDocument DLL (depending on how you build your application).
User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 425
Joined: Fri Dec 09, 2016 7:28 am
Contact:

Re: PDF/A-1 ISO 19005-1:2005 How to?

Post by cutecode »

strange, but I opened 2.pdf in an editor and at the top I see the same line which I just commented out

Code: Select all

%PDF-1.4
3 0 obj
<</Type /Page
/Parent 1 0 R
/Resources 2 0 R
/Annots []
/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>
/Contents 4 0 R>>
end
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru
User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 425
Joined: Fri Dec 09, 2016 7:28 am
Contact:

Re: PDF/A-1 ISO 19005-1:2005 How to?

Post by cutecode »

)))
Just doing it
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru
User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 425
Joined: Fri Dec 09, 2016 7:28 am
Contact:

Re: PDF/A-1 ISO 19005-1:2005 How to?

Post by cutecode »

Now only this error

Code: Select all

DeviceRGB may be used only if the file has a PDF/A-1 OutputIntent that uses an RGB colour space
Attachments
3.pdf.zip
(47.7 KiB) Downloaded 165 times
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru
User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 425
Joined: Fri Dec 09, 2016 7:28 am
Contact:

Re: PDF/A-1 ISO 19005-1:2005 How to?

Post by cutecode »

strange
version became %PDF-1.3
3 0
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: PDF/A-1 ISO 19005-1:2005 How to?

Post by utelle »

cutecode wrote: Mon Nov 16, 2020 10:32 pm strange
version became %PDF-1.3
3 0
Nothing to worry about. wxPdfDocument sets the PDF version depending on features used. Version 1.4 is set as soon as a graphics with transparency is added to the document. For your document this is not the case. Therefore the version remains at 1.3.
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: PDF/A-1 ISO 19005-1:2005 How to?

Post by utelle »

cutecode wrote: Mon Nov 16, 2020 10:25 pm Now only this error

Code: Select all

DeviceRGB may be used only if the file has a PDF/A-1 OutputIntent that uses an RGB colour space
Well, I'm at a loss. Obviously, it didn't help to remove the transparency group attributes. I guess the problem is now that the color for writing text is specified as an RGB color. Theoretically, it would be possible to use CMYK or Grayscale colors, but this would require quite some changes to the wxPdfDC code. So, probably it will be necessary to add PDF/A-1 OutputIntent attributes to the PDF document. However, at least at the moment this is not supported by wxPdfDocument. Right now I have no idea how complex that is to achieve. I would have to dig in the PDF reference to find out what has to be done. In principle, I'm willing to add PDF/A support to wxPdfDocument somehow, but this may take some time.
User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 425
Joined: Fri Dec 09, 2016 7:28 am
Contact:

Re: PDF/A-1 ISO 19005-1:2005 How to?

Post by cutecode »

no its my fault
I rebuilded wxPdf with an old version

I rebuilded it with my current sources and version become again 1.4
And errors became the same

Code: Select all

eviceRGB may be used only if the file has a PDF/A-1 OutputIntent that uses an RGB colour space
Absolute real value must be less than or equal to 32767.0
Attachments
4.pdf.zip
(47.74 KiB) Downloaded 159 times
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru
User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 425
Joined: Fri Dec 09, 2016 7:28 am
Contact:

Re: PDF/A-1 ISO 19005-1:2005 How to?

Post by cutecode »

utelle wrote: Mon Nov 16, 2020 11:02 pm I'm willing to add PDF/A support to wxPdfDocument somehow, but this may take some time.
I hope only on you!!!

Thank you
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: PDF/A-1 ISO 19005-1:2005 How to?

Post by utelle »

cutecode wrote: Mon Nov 16, 2020 11:06 pm no its my fault
I rebuilded wxPdf with an old version

I rebuilded it with my current sources and version become again 1.4
In fact, not surprising. It slipped my memory that extended graphics states (as used internally by wxPdfDC) also force version 1.4.
cutecode wrote: Mon Nov 16, 2020 11:06 pm And errors became the same

Code: Select all

eviceRGB may be used only if the file has a PDF/A-1 OutputIntent that uses an RGB colour space
Absolute real value must be less than or equal to 32767.0
As said in my previous post, it will be necessary to add explicit PDF/A support (specifying output intent and whatever else is required).
Post Reply