Hi,
Thanks for confirming that it works! Yes. We would prefer you to start a new thread for a new question in the future.
The PDF file size is something that can be optimized but it will largely depend on what's causing it. It's usually caused by one of the two things: images and font. If it is caused by image, then it is possible for you to replace the images as jpg images and that should reduce the file size significantly. If it is caused by font, then there usually isn't a lot you can do.
Currently our converter does not have an option to automatically save image as jpg (some other converters automatically save images as jpg but some people don't want that because jpg compression is lossy). We will add an option to allow you to explicitly specify whether you want to automatically do jpeg compression on images in the future.
It is possible for you to replace your image with jpgs even before we implement it as an option on our converter. The basic steps are:
1. Skip all images when you call ConvertHtml or ConvertUrl. This can be easily done by applying the following CSS on your page:
Code: CSS
img { visibility: hidden; }
This will skip all images but reserve space for all images. You can also run this as a test to see whether your file size is caused by the images. If the file size is significantly smaller without the images, then it is caused by your images;
2. ConvertHtml and ConvertUrl will return a HtmlToPdfResult object. From that object you can use one of the “result.HtmlDocument.GetElementXXXX” function to get your image “Element” object. That object will tell you where the image appears on the PDF output (page index, location, size, etc);
3. Construct an AcmImage object using a jpg image, then render that AcmImage at the location returned by step 2. The code would be something like this:
Code: C#
//Create an AcmRender for the page (returned by step 2)
AcmRender render = new AcmRender(page);
//Create an AcmImage object. Here you will need to load
//the image you wish to "fill in" into a System.Drawing.Image
//object. If that object is jpeg, then it will be saved as is in
//the PDF file
AcmImage image = new AcmImage(your_system_drawing_image_object);
//Use an AcmBlock to position the image. Here we assume
//we do not need to stretch the image
AcmBlock block = new AcmBlock(image);
block.Style.Left = X;
block.Style.Top = Y;
//"Fill in" the image
render.Render(image);
This should save the image as jpeg in your pdf file. If you have a lot of images, then it should reduce your file size significantly.
This method can also be used to fill in high quality image. So we have a sample in the demo project at All Demos -> Html to PDF -> Advanced -> High Resolution Images that demonstrates this technique. You can take a look of the source code of that sample to see how it works.
Hope this helps. Please feel free to let us know if you have any more questions.
Thanks!