static void Main(string[] args) { PdfDocument document = new PdfDocument("pdf's/CS 369 REGISTRATION.pdf"); PdfPageCollection pageCollection = document.Pages; PdfPage page = pageCollection[0]; PDFiumBitmap bitmap = new PDFiumBitmap(300, 300, true); //From my understanding, this renders the PdfPage to the bitmap. The bitmap is simply the target. page.Render(bitmap); Stream stream = new MemoryStream(); document.Save(stream); /*try{ * PdfDocument document = PdfDocument.Load("pdf's/CS 369 REGISTRATION.pdf"); * var bitMapImg = document.Render(1, 300, 300, true); * bitMapImg.Save("pdf's", ImageFormat.Png); * }catch(FileNotFoundException ex){ * Console.WriteLine("File Not Found"); * * }catch(System.BadImageFormatException ex1){ * Console.WriteLine("Incorrect Image Format"); * }*/ }
private void AddPdfDocument(PdfPageCollection pages) { foreach (PdfPage page in pages) { Doc.AddPage(page); PageNumbering(Doc.Pages.Count - 1); } }
public double GetTotalPageHeight(PdfDocument document) { PdfPageCollection pages = document.Pages; double height = 0; for (int i = 0; i < pages.Count; i++) { height += pages[i].Height; } System.Diagnostics.Debug.WriteLine(height.ToString()); return(height); }
public void SaveAllText() { PdfDocument document = GetDocument(); PdfPageCollection pages = document.Pages; pageCount = pages.Count; for (int i = 0; i < pageCount; i++) { File.Create(HostingEnvironment.MapPath("~/TestImages/" + i + ".txt")); //File.Write } }
public HtmlGenericControl DisplayAllPages() { HtmlGenericControl div = new HtmlGenericControl("div"); PdfDocument document = GetDocument(); PdfPageCollection pages = document.Pages; pageCount = pages.Count; for (int pageNum = 0; pageNum < pageCount; pageNum++) { div.Controls.Add(DisplayPage(pageNum)); } return(div); }
public void SaveAllImages() { PdfDocument document = GetDocument(); PdfPageCollection pages = document.Pages; pageCount = pages.Count; if (pageCount < 2) { return; } else { for (int pageNum = 2; pageNum < pageCount; pageNum++) { SaveImage(pageNum); } } }
public void SaveFirstImages() { PdfDocument document = GetDocument(); PdfPageCollection pages = document.Pages; pageCount = pages.Count; try { for (int pageNum = 0; pageNum < 2; pageNum++) { if (pageNum < pages.Count) { SaveImage(pageNum); } } }catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.ToString()); } }
private static void DrawPageNumber(PdfPageCollection pages, PdfMargins margin, int startNumber, int pageCount) { var brush = PdfBrushes.Black; var pen = new PdfPen(brush, 2f); var font = new PdfTrueTypeFont(new Font("Arial", 9f, System.Drawing.FontStyle.Italic), true); var format = new PdfStringFormat(PdfTextAlignment.Right) { MeasureTrailingSpaces = true }; var space = font.Height * 0.75f; var x = margin.Left; foreach (PdfPageBase page in pages) { page.Canvas.SetTransparency(1f); var width = page.Canvas.ClientSize.Width - margin.Left - margin.Right; var y = page.Canvas.ClientSize.Height - margin.Bottom + space; page.Canvas.DrawLine(pen, x, y, x + width, y); var numberLabel = $"{startNumber++} of {pageCount}"; page.Canvas.DrawString(numberLabel, font, brush, x + width, y, format); } }