Tips for generating PDF from HTML and making PDF smaller

Question:I'm generating PDF from HTML from C# and the files are coming out a reasonable size. However, I'm interested in any tips anyone has for making the PDF as small as possible.The HTML being rendered is really basic, just a table of names and dates etc - doesn't have to be too pretty. Is there any solution on VeryDOC?

Answer: If you need to generate PDF from C#, software VeryDOC Doc Converter COM can help you do that. But this software can not help you compress output PDF to a reasonable size. It will output PDF from HTML with high quality to make the output PDF keeping all the original elements of HTML file.  If you need to compress PDF to a reasonable size, you’d better compress it with some professional tool like VeryDOC PDF Compressor, by it you can compress PDF according to its size. Say the PDF is text based, you can compress PDF by compressing fonts. In the following part, I will show you how to generate PDF and make it smaller by those two software.

Step 1. Generate PDF from C#.

  • When generating PDF from C#, please download software VeryDOC Doc Converter COM. When downloading finishes, please unzip it and then use it like other COM version software.
  • When generating PDF from C#, please refer to the following code template:
  • Set PdfCreator = New PDFOUTLib.PdfCreator
            PdfCreator.HTML2PDF = "C:\sample.html"
            PdfCreator.FileName = "C:\sample.pdf"
            PdfCreator.HeadersFooters = "off"
            PdfCreator.paperType = 6 '//7 is A4 paper, 6 is A3 paper
            PdfCreator.CreatePDF
            While PdfCreator.StillRunning = 1
                DoEvents
                Call WaitMessage
            Wend
            Set PdfCreator = Nothing
            Debug.Print "C:\sample.html -->C:\sample.pdf"

Step 2. Compress PDF

  • When compressing PDF, please download PDF Compressor Command Line. When downloading finishes, please extract it to some folder then you can use it like other command line version software.
  • When compressing text based PDF, please refer to the following command line templates:
  • pdfcompressor.exe -winfont -embedallfonts -subsetfonts -compressfonts C:\in.pdf C:\out.pdf
    pdfcompressor.exe -subsetfonts C:\in.pdf C:\out.pdf
    Here are some parameters:
    -winfont             : Use Windows fonts to replace Base14 fonts
    -embedallfonts : Embed all fonts
    -subsetfonts      : Subset fonts
    -compressfonts : Compress fonts

By those two software, I guess we can generate PDF and compress PDF to a reasonable size. Now we have not one software which can process those two functions perfectly. But we will make one in the future. During the using, if you have any question, please contact us as soon as possible.

     

VN:F [1.9.20_1166]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *


Verify Code   If you cannot see the CheckCode image,please refresh the page again!