Hi,
I'm using GhostscriptRasterizer class to convert PDF file to jpg. After converting file in picture is visible not same characters as in PDF file.
This is code that I use to convert pdf:
private static void SwitchPDFtoJPG(string sPdfFile, string sPath, string binPath, byte[] pdf)
{
string path = "";
if (binPath != "")
{
path = binPath;
}
else
{
path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
}
GhostscriptRasterizer rasterizer = null;
var dllName = System.Configuration.ConfigurationManager.AppSettings["ghostscriptDllName"];
if (dllName == null)
dllName = "gsdll64.dll";
GhostscriptVersionInfo version = new GhostscriptVersionInfo(new Version(0, 0, 0), path + @"\" + dllName, string.Empty, GhostscriptLicense.GPL);
using (rasterizer = new GhostscriptRasterizer())
{
if (pdf != null)
{
var ms = new MemoryStream(pdf);
rasterizer.Open(ms, version, false);
}
else
{
rasterizer.Open(sPdfFile, version, false);
}
if (rasterizer.PageCount > 0)
{
string pageFilePath = string.Format("{0}\\{1}.jpg", sPath, Path.GetFileNameWithoutExtension(sPdfFile));
Image img = rasterizer.GetPage(200, 200, 1);
img.Save(pageFilePath, ImageFormat.Jpeg);
}
rasterizer.Close();
}
}
Comments: ** Comment from web user: indulis **
I'm using GhostscriptRasterizer class to convert PDF file to jpg. After converting file in picture is visible not same characters as in PDF file.
This is code that I use to convert pdf:
private static void SwitchPDFtoJPG(string sPdfFile, string sPath, string binPath, byte[] pdf)
{
string path = "";
if (binPath != "")
{
path = binPath;
}
else
{
path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
}
GhostscriptRasterizer rasterizer = null;
var dllName = System.Configuration.ConfigurationManager.AppSettings["ghostscriptDllName"];
if (dllName == null)
dllName = "gsdll64.dll";
GhostscriptVersionInfo version = new GhostscriptVersionInfo(new Version(0, 0, 0), path + @"\" + dllName, string.Empty, GhostscriptLicense.GPL);
using (rasterizer = new GhostscriptRasterizer())
{
if (pdf != null)
{
var ms = new MemoryStream(pdf);
rasterizer.Open(ms, version, false);
}
else
{
rasterizer.Open(sPdfFile, version, false);
}
if (rasterizer.PageCount > 0)
{
string pageFilePath = string.Format("{0}\\{1}.jpg", sPath, Path.GetFileNameWithoutExtension(sPdfFile));
Image img = rasterizer.GetPage(200, 200, 1);
img.Save(pageFilePath, ImageFormat.Jpeg);
}
rasterizer.Close();
}
}
Comments: ** Comment from web user: indulis **
Here is PDF file that was used to get this picture