I have an application where they scan from a copier and it saves it to file. The application then loops through that file and creates several splits into individual documents. The original PDF is in portrait. However, the new document gets switched to landscape and cuts off the bottom of the page.
In my last line of code here, the image saved is cut off. I use a particular area of this image and use an OCR to determine a document number. I've attached the original PDF as well as the new document (pdfToSave).
This only happens from one scanner, but I cannot figure out how to make it correct.
PdfDocument original = new PdfDocument();
PdfDocument pdfToSave = new PdfDocument();
//original.LoadFromFile(e.FullPath);
original.LoadFromFile(f.FullPath, FileFormat.PDF);
original.PageSettings.Orientation = PdfPageOrientation.Portrait;
//Log file received file and size
EventLog.WriteEntry(source , f.Name + " received, " + original.Pages.Count + " pages."
, EventLogEntryType.Information);
//Loop thu each page
for (int i = 1; i <= original.Pages.Count; i++)
{
PdfDocument pageTemp = new PdfDocument();
PdfPageBase page;
string pageId = i.ToString();
string pathHeader = tempPath + @"\" + f.Name + "-" + pageId + "-Header.bmp";
string pathBarcode = tempPath + @"\" + f.Name + "-" + pageId + "-BarCode.bmp";
string pathBarcode2 = tempPath + @"\" + f.Name + "-" + pageId + "-BarCode2.bmp";
string pathPage = tempPath + @"\" + f.Name + "-" + pageId + ".bmp";
pageTemp.PageSettings.Orientation = PdfPageOrientation.Portrait;
page = pageTemp.Pages.Add(original.Pages[i - 1].Size, new Spire.Pdf.Graphics.PdfMargins(0));
original.Pages[i - 1].CreateTemplate().Draw(page, new System.Drawing.PointF(0, 0));
Image image = pageTemp.SaveAsImage(0);
image.Save(pathPage);
//Other logic that does not modify pdfToSave...
pdfToSave.InsertPage(pageTemp, page);
pdfToSave.SaveToFile(outputPdfPath + @"\" + strWO + ".pdf");