Save as PDF/X-3/4/5 error with pdflib
【現象】Save as PDF/X-3/4/5,導出的pdf錯誤,打不開,文件是空的。
【原因】
我們設置的文字顏色是RGB Color Space,但是我們設置的PDF/X-3/4/5默認的output intent是CMYK的Color Space,所以調用fit_textline函數寫文字時,就會拋異常“RGB Color Space requires suitable output intent in pdf/x-3/4/5”。
PDF/X是PDF的一種特殊規格,它比普通PDF規格多一些限制,詳見Wiki。
以下是pdflib列出的一些PDF/X的限制:
PDF/X Some options are restricted.
PDF/X-1a: RGB images are notallowed.
PDF/X-1a/3: JBIG2 images are notallowed.
PDF/X-3/4/5: Grayscale imagesrequire that the defaultgray option in PDF_begin_page_
ext( ) must have been set unless theoutput intent is a grayscale or CMYK device.
RGB images require that thedefaultrgb option in PDF_begin_page_ext( ) must have
been set unless the output intent isan RGB device.
CMYK images require that thedefaultcmyk option in PDF_begin_page_ext( ) must
have been set unless the outputintent is a CMYK device.
JPEG 2000 images must satisfycertain conditions; see PDFlib Tutorial for details.
【解決辦法】
if(g_lPDFSyle== NS_PDF_X3 || g_lPDFSyle == NS_PDF_X4 || g_lPDFSyle == NS_PDF_X5){TCHARoptlist[MAX_PATH]=_T("");int icc = pPdf->load_iccprofile(TEXT("sRGB"), _T(""));_stprintf(optlist,_T("defaultrgb=%d"), icc);pPdf->begin_page_ext(fPageW,fPageH,optlist);}else{pPdf->begin_page_ext(fPageW,fPageH,_T(""));}?
總結
以上是生活随笔為你收集整理的Save as PDF/X-3/4/5 error with pdflib的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 是选择Keras还是PyTorch开始你
- 下一篇: 什么是黑链?常见的黑链代码?