我的应用程序使用 Ghostscript 在图片框中显示 PDF。我使用的 PDF 是带有文本层的扫描图像。由 Acrobat Pro 的 OCR 功能创建。此 OCR 功能会根据文本的方向自动设置方向。当页面显示在图片框中时,此信息将丢失。它只是以纵向模式显示每一页。
Ghostscript 有没有办法访问 PDF 的这个属性并在图片框中以正确的方向显示它?
public Form1()
{
InitializeComponent();
_viewer = new GhostscriptViewer();
_viewer.DisplaySize += new GhostscriptViewerViewEventHandler(_viewer_DisplaySize);
_viewer.DisplayPage += new GhostscriptViewerViewEventHandler(_viewer_DisplayPage);
NumberOfPagesToExtract = 1;
_viewer.Open("NoFile.pdf", _gsVersion, true);
}
void _viewer_DisplaySize(object sender, GhostscriptViewerViewEventArgs e)
{
pictureBox1.Image = e.Image;
}
void _viewer_DisplayPage(object sender, GhostscriptViewerViewEventArgs e)
{
pictureBox1.Invalidate();
pictureBox1.Update();
currentPageNumber = _viewer.CurrentPageNumber;
LastPageNumber = _viewer.LastPageNumber;
lblTotalNmbPages.Text = " / " + LastPageNumber.ToString();
txtCurrentPgNmbr.Text = currentPageNumber.ToString();
}
打开文件的代码:
private void btnOpenPdfGhostScript_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Title = "Open PDF file";
ofd.Filter = "PDF, PS, EPS files|*.pdf;*.ps;*.eps";
if (ofd.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
{
btnCLose_Click(this, null);
_viewer.Open(ofd.FileName, _gsVersion, true);
currentFilePath = ofd.FileName;
currentPageNumber = _viewer.CurrentPageNumber;
LastPageNumber = _viewer.LastPageNumber;
lblCurrentFIle.Text = ofd.FileName; //System.IO.Path.GetFileName(ofd.FileName);
if (backgroundWorker1.IsBusy != true) backgroundWorker1.RunWorkerAsync();
}
currentPageNumber = 1;
progressBar1.Value = 0;
}