[英]Ghostscript PDF to TIFF setting output size c#
I have a pdf of 22 pages. 我有22页pdf。 I am using GhostScript to convert the PDF to TIFF to be used by Tesseract.
我正在使用GhostScript将PDF转换为Tesseract使用的TIFF。 I did this...
我做了这个
string filename=openFileDialog1.FileName;
using (GhostscriptRasterizer rasterizer = new GhostscriptRasterizer())
{
rasterizer.Open(filename, _lastInstalledVersion, false);
for (int pageNumber = 1; pageNumber <= rasterizer.PageCount; pageNumber++)
{
Image img = rasterizer.GetPage(400, 400, pageNumber);
}
I want to set the img size before I pass it to be used by Tesseract but I cant.. Is there any way? 我想先设置img大小,然后再将其传递给Tesseract使用,但我不能。
There is this example: but idk if I can pass each image from the pdf to be used by Tesseract 有这个例子:但是如果我可以通过pdf传递每个图像以供Tesseract使用,则为idk
GhostscriptVersionInfo gv = GhostscriptVersionInfo.GetLastInstalledVersion();
using (GhostscriptProcessor processor = new GhostscriptProcessor(gv, true))
{
processor.Processing += new GhostscriptProcessorProcessingEventHandler(processor_Processing);
List<string> switches = new List<string>();
switches.Add("-empty");
switches.Add("-dSAFER");
switches.Add("-dBATCH");
switches.Add("-dNOPAUSE");
switches.Add("-dNOPROMPT");
switches.Add(@"-sFONTPATH=" + System.Environment.GetFolderPath(System.Environment.SpecialFolder.Fonts));
switches.Add("-dFirstPage=" + pageFrom.ToString());
switches.Add("-dLastPage=" + pageTo.ToString());
switches.Add("-sDEVICE=png16m");
switches.Add("-r96");
switches.Add("-dTextAlphaBits=4");
switches.Add("-dGraphicsAlphaBits=4");
//switches.Add("-sDEVICE=pdfwrite");
switches.Add(@"-sOutputFile=" + outputFile);
switches.Add(@"-f");
switches.Add(inputFile);
processor.StartProcessing(switches.ToArray(), null);
}
}
-dDEVICEWIDTHPOINTS and -dDEVICEHEIGHTPOINTS, along with -dFIXEDMEDIA will set a specific media size. -dDEVICEWIDTHPOINTS和-dDEVICEHEIGHTPOINTS以及-dFIXEDMEDIA将设置特定的介质大小。 You'll probably want to set -dPDFFitPage as well to scale the content onto the new media.
您可能还需要设置-dPDFFitPage,以将内容缩放到新媒体上。
You can't be using Ghostscript directly, are you using jhabjan's Ghostscript.net ? 您不能直接使用Ghostscript,使用的是jhabjan的Ghostscript.net吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.