Menu
Active2 years, 5 months ago
I want to convert a text file to PDF using PDFsharp. What should be the approach? Is it even possible? I'm developing a web application using C#.net
Vive la déraisonOct 07, 2007 Hi all, How can i convert a PDF to JPG image page by page. Also I wish to save the images with the page number as file name. For Eg: If the PDF has 5 Pages. The first page should be converted as jpg and saved in the name as 1.jpg, for the second page 2.jpg.5.jpg Is it possible to create this wit There is a GNU project out there called PDF Sharp. I want to convert a text file to PDF using PDFsharp. What should be the approach? Is it even possible? I'm developing a web application using C#.net.
16.3k22 gold badges5656 silver badges119119 bronze badges
Gk_999Gk_999
2 Answers
The approach would be to check the samples for PDFsharp and MigraDoc and then decide which tool to use.
I would guess that MigraDoc will be the better choice if the text may require more than just one page.
See also:
http://pdfsharp.net/wiki/MigraDocSamples.ashx
Vive la déraisonVive la déraisonhttp://pdfsharp.net/wiki/MigraDocSamples.ashx
16.3k22 gold badges5656 silver badges119119 bronze badges
I wrote down a code for this purpose.
Initially, i used pdfsharp dll for this, but this did not work for me since pdfsharp can not sense page breaks, when i wrote my code, i saw that only the ones which fit in the first page is printed.
Then i learnt that Migradoc does sense page breaks and add new pages if needed automatically.
Here is my method with two parameters:
And call this method with input text full path and output pdf file full path to create.
This works.
user4805530
Not the answer you're looking for? Browse other questions tagged converterpdfsharp or ask your own question.
Active8 months ago
How to export a PDF page as an image using PDFsharp .NET library, for pixel level manipulation?
For example, something like, System.Drawing.BitMap.GetPixel()
I am trying to find out empty area (all white, or of any colour) inside a PDF document, to write some graphics / image.
09, June 2010:
I have tried this, but it is not working.
Why the following code is not working as expected?
Bitmap.GetPixel always returns 0.
Vive la déraison16.3k22 gold badges5656 silver badges119119 bronze badges
vi.su.vi.su.30522 gold badges66 silver badges1919 bronze badges
1 Answer
The answer can be found in the PDFsharp FAQ list:http://www.pdfsharp.net/wiki/PDFsharpFAQ.ashx#Can_PDFsharp_show_PDF_files_Print_PDF_files_Create_images_from_PDF_files_3
Convert Image To Word
PDFsharp creates PDF files, but it cannot render them.
The call
Pdfsharp Multiple Images
does not initialize any bits of the bitmap and does not copy anything from the Graphics object except for the DPI setting of the Graphics object. Graphics objects draw things, but they do not remember what they have drawn and they cannot re-create the drawings in a call to
new Bitmap(...)
. This does not work with the Graphics class from Microsoft, this does not work with the XGraphics class from PDFsharp either.Pdfsharp Convert Image To Pdf Online
The XGraphics class from PDFsharp can be used to draw on PDF pages and it can be used to draw on bitmaps, on a printer, or on the screen - it can draw on PDF pages and on any DC you can get from Windows. Same goes for MigraDoc.
So if you want to create PDF files and bitmaps with the same contents, PDFsharp and MigraDoc can help.
So if you want to create PDF files and bitmaps with the same contents, PDFsharp and MigraDoc can help.
But PDFsharp does not provide any way to render a PDF page to a bitmap.
Vive la déraisonVive la déraison16.3k22 gold badges5656 silver badges119119 bronze badges