我的應用程序使用Ghostscript在圖片框中顯示PDF。我使用的PDF是帶有文本圖層的掃描圖像。由Acrobat Pro的OCR功能創建。該OCR功能根據文字的方向自動設置方向。當頁面顯示在圖片框中時,此信息將丟失。它只是以縱向模式顯示每一頁。使用Ghostscript查看PDF的方向
有沒有辦法讓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;
}
嗨,你使用什麼Ghostscript.NET版本?最新版本(1.1.8)已解決定位問題。 – HABJAN
謝謝HABJAN。升級問題修復後,我正在使用1.1.4。超!!!! –