PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
Creates too large a file https://forum.pdfsharp.net/viewtopic.php?f=2&t=772 |
Page 1 of 1 |
Author: | jkruger [ Wed Jul 01, 2009 2:06 pm ] |
Post subject: | Creates too large a file |
I have successfully implemented a few web services using PDF Sharp. Unfortunately I am a bit stumped by the file size of the output - in my case I experimented with text only - and a 70 page report turns out to be 24.5MB without images. Am I missing something, should I be rendering the document in another way? I looked through the examples but haven't found anything similar to my issue. Thanks for any comments or help. |
Author: | Thomas Hoevel [ Wed Jul 01, 2009 3:12 pm ] |
Post subject: | Re: Creates too large a file |
The release build creates smaller files. But even the debug build shouldn't create files without images of that size. No images? Well, how many different fonts are you using? Not long ago I played with a Word macro that enumerated all fonts on the computer ... |
Author: | jkruger [ Wed Jul 01, 2009 3:49 pm ] |
Post subject: | Re: Creates too large a file |
Thomas Thanks for your quick reply - I use only one font - Verdana - we also have our own font which we plan to use in other portions, but it is not being used in these documents. Before creating this application, I created a test app which produces only 7 pages - and it turns out to be 2.3MB. I am using the 1.2.1269-g version. There is no compress function that I should be using - I found none in the samples: pretty much this is the structure I use: Set document variable open document add page create text add page create text etc save document close document Thanks Johan Kruger |
Author: | Thomas Hoevel [ Thu Jul 02, 2009 8:25 am ] |
Post subject: | Re: Creates too large a file |
Hi, Johan! If you want to find out what makes the file so big, you could
|
Author: | jkruger [ Thu Jul 02, 2009 12:38 pm ] |
Post subject: | Re: Creates too large a file |
Thanks Thomas I think I know why the file is so big, and that will bring me to a question about formatting. I put a smaller file (9MB) on there, the comcept is the same. This one contains images though (but I don't think that the problem is the images). I put the file on www.astrologysoftware.com/eros008jk.pdf The problem I think is this - I build the paragraphs in a certain way because of alternate format proportions - I thought that doing it this way will give me more control over where I can put text, but it leads to me putting a whole lot of objects on pages. My question thus is: Can I build this kind of formatting in another way without sacrificing the control over it? Things like italic/bold/images inside of paragraphs is something I'd like to control, and controlling which paragraphs belong together without splitting them over 2 pages etc, but it means that I am using DrawString to put each word down separately. And I think that is where the problem is? If you have the time I'd appreciate your feedback. Thank you again. Johan Kruger |
Author: | Thomas Hoevel [ Thu Jul 02, 2009 1:26 pm ] |
Post subject: | Re: Creates too large a file |
Johan, you are using a DEBUG build (if you open that PDF file with WordPad you'll see "% PDFsharp Version 1.2.1269.0 (verbose mode)"). A RELEASE build uses the non-verbose mode automatically - and filesize should fall to 25% through 50% or so (depending on the file). Your file really contains a lot of objects. MigraDoc is my area of expertise - and a 50 page document created with QBX 2008 and MigraDoc contains 563 objects in the PDF file (avg. of 11 objects per page). Your document with 34 pages has 37974 objects ... The file contains many empty objects. And in verbose mode this looks like: Code: %-------------------------------------------------------------------------------------------------- 37861 0 obj % PdfSharp.Pdf.Advanced.PdfContent << /Length 0 >> stream endstream endobj %-------------------------------------------------------------------------------------------------- Maybe they come from drawing spaces ... Here's the code that draws "is": Code: 37862 0 obj % PdfSharp.Pdf.Advanced.PdfContent << /Length 86 >> stream q 1 0 0 -1 0 792 cm -100 Tz q BT /GS0 gs /F0 -10 Tf 493.49 456.8561 Td (is) Tj ET Q Q endstream endobj You guessed it: drawing more text with identical font settings should reduce the file size. But try a RELEASE build first - just to see how much smaller files will be. Then stop drawing spaces - this should also save a few bytes. |
Author: | jkruger [ Thu Jul 02, 2009 3:17 pm ] |
Post subject: | Re: Creates too large a file |
Thomas Yes, I was using a debug version, didn't even occur to me that that could have been an issue. And your other suggestions are right on, somehow I am going to have to find a way of creating blocks of writable text - anyway, thanks for your input - I will keep you up to date if I come across anything that might help someone else - but I did manage to save about 46% on the file size (24MB down to 13MB, 9MB down to 5MB etc) by just making it a release version. Thanks Johan Kruger |
Author: | fy04 [ Tue May 11, 2010 8:34 pm ] |
Post subject: | Re: Creates too large a file |
Hi, I am using migraDoc in the asp.net page. I did not find any option to build the website as a release version. I tried to publish the site and the pdf it generated still showed me the verbose mode (PDFsharp Version 1.31.1789.0 (verbose mode)). From sample, pdfDocument can set document.Options.CompressContentStreams = true. Any thing that works for MigraDoc.DocumentObjectModel document? Thanks in advance. Yang |
Author: | Thomas Hoevel [ Wed May 12, 2010 7:10 am ] |
Post subject: | Re: Creates too large a file |
Hi! fy04 wrote: I did not find any option to build the website as a release version. Create a Release build for MigraDoc and PDFsharp. In the Visual Studio toolbar there's a dropdown listbox that allows to select between Release and Debug. |
Author: | fy04 [ Wed May 12, 2010 5:57 pm ] |
Post subject: | Re: Creates too large a file |
Thank you. It worked. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |