如何使用GhostScript DLL将PDF转换为PDF/A。我知道我必须调用名为gsapi_init_with_args的gsdll32.dll的导出函数,但是如何传递正确的参数?顺便说一句,我使用的是C#。如何使用Ghostscript DLL将PDF转换为PDF/A
2
A
回答
3
请尝试从命令行运行此命令以测试它是否正在执行您所需的操作。
gswin32.exe -dPDFA -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=PDFA.pdf 1.pdf
0
取决于你的检查工具做报告什么确切的偏离标准......您可能需要改变你的PDFA_def.ps
以适应你的环境(和您可能需要动态地重新写入的内容文件为每个新的PDF/A转换)。这是一个简短的文件,很好的评论。
尝试添加-Ic:/路径/到/ gsinstalldir/lib目录和PDFA_def.ps
到命令行哔叽直接调用提示:
gswin32c.exe^ -Ic:/path/to/gsinstalldir/lib^ -dPDFA^ -dBATCH^ -dNOPAUSE^ -dUseCIEColor^ -sDEVICE=pdfwrite^ -sOutputFile=output-PDFA.pdf^ PDFA_def.gs^ input.pdf
或
gswin32c.exe^ -Ic:/path/to/gsinstalldir/lib^ -dPDFA^ -dBATCH^ -dNOPAUSE^ -dUseCIEColor^ -sDEVICE=pdfwrite^ -sOutputFile=output-PDFA.pdf^ c:/path/to/customized/PDFA_def.gs^ input.pdf
测试命令行第一,然后按照推荐的方式进行。
1
我已经受够了工作使用从ghostscriptsharp如下:
[DllImport("gsdll32.dll", EntryPoint = "gsapi_new_instance")]
private static extern int CreateAPIInstance(out IntPtr pinstance, IntPtr caller_handle);
[DllImport("gsdll32.dll", EntryPoint = "gsapi_init_with_args")]
private static extern int InitAPI(IntPtr instance, int argc, string[] argv);
[DllImport("gsdll32.dll", EntryPoint = "gsapi_exit")]
private static extern int ExitAPI(IntPtr instance);
[DllImport("gsdll32.dll", EntryPoint = "gsapi_delete_instance")]
private static extern void DeleteAPIInstance(IntPtr instance);
private static void CallAPI(string[] args)
{
IntPtr gsInstancePtr;
lock (resourceLock)
{
CreateAPIInstance(out gsInstancePtr, IntPtr.Zero);
try
{
int result = InitAPI(gsInstancePtr, args.Length, args);
if (result < 0)
{
throw new ExternalException("Ghostscript conversion error", result);
}
}
finally
{
Cleanup(gsInstancePtr);
}
}
}
private static object resourceLock = new object();
private static void Cleanup(IntPtr gsInstancePtr)
{
ExitAPI(gsInstancePtr);
DeleteAPIInstance(gsInstancePtr);
}
args
会像字符串数组:
- “-sDEVICE = pdfwrite”
- “-dPDFA “
- ...
相关问题
- 1. Ghostscript的 - 将PDF转换为PDF/A
- 2. 如何使用Ghostscript将XPS转换为PDF或将XPS转换为DOC?
- 3. 如何使用ghostscript将PDF转换为PNG?
- 4. 如何使用Ghostscript将PDF转换为Word?
- 5. 将PDF转换为使用ImageMagick/Ghostscript的JPG时文件太大
- 6. 使用Ghostscript将PCL转换为PostScript
- 7. 通过Ghostscript将PDF文件转换为PDF/A
- 8. 如何在使用Ghostscript将PDF转换为EPS轮廓时保留边距?
- 9. VB dLL将pdf转换为tiff
- 10. 的ghostscript如何留住PDF大小,同时将PDF转换为灰度
- 11. 如何使用Ghostscript将psd(photoshop文件)或tiff转换为PNG?
- 12. 如何使用ghostscript将CMYK eps转换为CMYK jpeg?
- 13. 错误将PDF转换为PDF/A
- 14. 当转换为PCL时,ghostscript将pdf中的文本转换为图形
- 15. XFA格式转换为PDFA-1B
- 16. 如何将html转换为pdf与PDF?
- 17. 将EPS转换为PDF的Ghostscript命令行参数
- 18. ghostscript在将pdf转换为ps时给出错误
- 19. 将PDF转换为JPG时出现Ghostscript错误
- 20. 将Imagemagick/GhostScript转换为jpeg/png忽略pdf背景
- 21. 错误将PDF转换为PNG - 的Python 3.6和Ghostscript
- 22. 使用GhostScript的
- 23. 在Windows .bat文件中使用ghostscript将多个pdf文件转换为PNG
- 24. 如何使用SVG图形将PDF转换为PDF文件?
- 25. Ghostscript:如何将EPS转换为具有相同页面大小的PDF
- 26. 转换列表使用Ghostscript
- 27. GhostScript PDF转换出现问题
- 28. PHP将PDF转换为图像-dUseCropBox
- 29. 在Linux上将PDF转换为PDF/A的命令行? ghostscript的注解问题
- 30. 使用ikvm将罐子转换为dll
嗨,我现在使用gsdll32.dll,所以没有gswin32.exe可用。我必须调用gsapi_init_with_args。从GhostScript网站,我得到了这样的: gs -dPDFA -dBATCH -dNOPAUSE -dNOOUTERSAVE -dUseCIEColor -sDEVICE = pdfwrite -sOutputFile = out-x3.pdf PDFA_def.ps input.pdf 但是当我使用参数与gsapi_init_with_args结果PDF不正确,它报告它不符合任何标准。所以这很棘手。任何人都可以帮忙 – imgen 2009-11-13 04:57:16
其实它并不棘手,我给你一个命令行gswin32.exe为了确保-dPDFA和其余的交换机正常工作,你应该有你的安装gswin32.exe,因为我看到你'使用ghostscript获胜。只需运行我给你的线路来检查它是否有效。在你确定命令有效之后,你可以将它翻译成gsapi_init_with_args调用 问候 – 2009-11-13 14:23:15