PDFsharp & MigraDoc Forum https://forum.pdfsharp.net/ |
|
PDFSharp open existing document has no pages https://forum.pdfsharp.net/viewtopic.php?f=2&t=3180 |
Page 1 of 1 |
Author: | pwl2706 [ Tue Aug 25, 2015 1:54 pm ] |
Post subject: | PDFSharp open existing document has no pages |
Hi, I am new to PDFSharp. I have a PDF document consisting of a table with some data saved on my hard drive by my c# service. The size of the table is actually meant to print on a compliments slip sized page, so about 1/3 of an A4 page. I need to rotate the table by 90" then save it back, as the paper for these cashier receipts needs to be fed long-wise into the printer using the manual feed tray. So I tried the below code to open an existing document: Code: // Rotate and save the PDF; PdfDocument doc = new PdfDocument(reportName); ; var page = doc.Pages[0]; page.Rotate = 90; //Save pdf file. doc.Save("PDFSharp _" + reportName); doc.Close(); Before I run the above code, the document referenced by reportName is 25KB...after that line of code executes, the document is 0 bytes in size. So obviously I am creating a new document and overwriting my existing one. What is the correct method call to open an existing single page PDF, rotate it's single page, and save it? Thanks |
Author: | Thomas Hoevel [ Tue Aug 25, 2015 2:05 pm ] |
Post subject: | Re: PDFSharp open existing document has no pages |
Hi! There are many samples that modify (Watermark) or import (Two Pages on One, Combine Documents) PDF pages. Please check those samples to get started: http://www.pdfsharp.net/wiki/PDFsharpSamples.ashx Specifying a filename with "new PdfDocument(reportName)" allows to later call "Save()" without filename. It does not pretend to import the file. |
Author: | pwl2706 [ Tue Aug 25, 2015 2:08 pm ] |
Post subject: | Re: PDFSharp open existing document has no pages |
Thanks Thomas, I will take a look. In fact I managed to do it by the below: Code: // Rotate and save the PDF;
PdfDocument doc= PdfReader.Open(reportName); var page = doc.Pages[0]; page.Rotate = 90; //Save pdf file. doc.Save("PDFSharp _" + reportName); doc.Close(); |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |