PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.com/

Adding simple text increasing size of PDF dramatically
http://forum.pdfsharp.com/viewtopic.php?f=2&t=455
Page 1 of 1

Author:  sidpoonja [ Fri Aug 22, 2008 11:23 am ]
Post subject:  Adding simple text increasing size of PDF dramatically

I have an application that uses a GIS framework to export a PDF document (which is basically a map). I then need to stamp this PDF with some custom information (just two lines of simple text) for which I use PDFSharp and create a new PDF document. The utility works great. The only problem is that the size of the resultant document (created by PDFSharp) is so much larger. For eg: one PDF file that was orginally 184KB became 712KB when created with PDF Sharp. Now the PDF Exporter of the GIS framework has a DPI setting. Is there something similar with PDFSharp?

here is the code i used to generated the PDF.

pdfDocument = PdfReader.Open(inputFile)
For Each page As PdfPage In pdfDocument.Pages
Dim xgfx As XGraphics = XGraphics.FromPdfPage(page)
xgfx.DrawString("As of Date : " + effectiveDate, dateFont, XBrushes.Black, effDateLocation)
page.Close()
Next
pdfDocument.Save(outputFile)
pdfDocument.Close()

Author:  Thomas Hoevel [ Mon Aug 25, 2008 7:33 am ]
Post subject: 

Are you using a DEBUG build of PDFsharp?
Have you tried a RELEASE build?

Author:  sidpoonja [ Mon Aug 25, 2008 11:19 pm ]
Post subject: 

Hi Thomas,

Thanks for your reply. I was able to fix the problem. After I got a reference to the PDFDocument object, I set two of its properties:

PDFDocument.CompressContentStreams = True
PDFDocument.NoCompression = False

and that seemed to do the job. Now the size of the new PDF is only marginally larger than the original PDF (which is expected).

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/