Change quality of PDF rendered using PDFsharp - pdf-generation

Can we reduce the quality of PDF rendered using PDFsharp?
I have to render files containing thousands of pages. Due to this, the resulting files sometimes occupy more than 100 MB memory space which is inconvenient.
A PDF is rendered from an Excel sheet. There are no images or charts. Only the number of rows in the Excel is very high. Can anyone please help?
Thanks in advance

With the current version of PDFsharp it is up to you to reduce the resolution of images or the JPEG quality to optimize the file size.
.NET provides functions that can accomplish that.

Related

How to reduce the size of a crystal report with OLE image and datasets without loosing resolution

I am trying to reduce the size of a crystal report , where in I have converted the image from PDF to BMP and then inserted as an OLE object in to the crystal report. In doing so , The color (Black and white) was still rich and the words in the image are clear.
Using CR 2008
However, The crystal report size is increased to more than 8 megs , which is a lot for the report with a single page.
I have searched online on how to reduce the size of the CR , I have found one answer where , Use photoediting tools , the image to GreyScale and add as OLE object , however in doing so , the image resolution has gradually decreased.
I am still looking for a solution where I can decrease the size of the CR to less than 3 megs with out compromising the image quality in the report.
P.S: My first question on StackOverflow. :)
Do not convert to another format because Crystal manages the image internally as bitmap.
Reduce color depth. For example, convert from full color to grayscale.
Load the rpt in Crystal and go to
File, Report Options...
And turn on the checkbox for 'Retain Original Color Depth'.
If you need to resize the image, do so outside Crystal. Resizing an image inside Crystal can cause it to consume more memory.
I only stumbled across this question as you had Reporting Services tagged (I've now removed that tag from your question). I'm no Crystal Reports person but I suspect most of the file size is in the BMP. BMPs are uncompressed so they are big, especially compare to other file formats.
You should be able to convert to a PNG or JPEG with low compression and this will reduce the size of the image considerably. Play around with different compression levels when saving to see what works best but I would start at about 90%.
If you need a free (Windows) tool where you can set the compression when saving an image, try paint.net ( https://www.getpaint.net/ ) It's completely free, open source and simple.

Effect on existing images after changing JPEG quality (GD toolkit) in Drupal 7

On our Drupal 7 website with thousands of images, JPEG quality in GD toolkit was set at 100%.
This caused well-optimized images to be 150-200% larger if 'image styles' were used instead of 'original images'. But we need to use styles to keep images ratio consistent. CSS 'object-fit' is not an option for cross-browser reasons.
What will happen to the quality of existing images if we reduce quality to 60%?
Update: As far as I tested it should not have any effect on the existing images
(New) image style image (thumbnail) is generated if old one is not found. There is no point of re-generating thumbnails every time they are displayed since it would required too much server/resources.
If you want some thumbnail regenerated it should be enough to just delete thumbnail file. Next time it's called it will be generated again.
There is also a module for that: https://www.drupal.org/project/imagestyleflush
Check on this thread to see other options:
https://drupal.stackexchange.com/questions/12864/rebuild-images-from-image-style

Create small high quality PDF embedding optimized PNG?

I'm trying to create a small PDF file, embedding one optimized PNG image displayed as a header and footer on a 3 page PDF (same image must appear 6x in the PDF)
My optimized PNG image is only 2.3KB. It looks very sharp.
Failed with libreoffice
When I insert just one instance of the 2.3KB PNG image into a Libreoffice Writer doc containing only text, then export as PDF I can see that the image gets re-compressed to JPG and the resulting PDF file grows by about 40KB after adding the image. It also loses quality, the PNG also gets JPG fuzzy edges.
If I right click the image and select compression, there is no way to disable recompressing the image (it's already optimized better than libreoffice could do it) I've tried setting a compression level of 0,1,9 etc. Choosing JPG, no resize, lossless, etc but there was no improvement.
Failed with wkhtmltopdf
I also tried making a test page and used wkhtml2pdf but it did the same thing. Adding the low quality flag made no difference.
PDF Spec suggests PNG is supported?
From skimming the PDF spec, it looks like PNG images are supported.
Even plain text PDF files are surprisingly large
The disappointing thing is also when I take a 7KB HTML file which is basically just <html><body><p>foo...</p><p>bar...</p> (only about 15 paragraphs) with no CSS. The resulting 2 page PDF file is 30KB. Why should a 7kb (almost plain text) file become 30kb as a PDF?
Suggestions?
Can someone please suggest how to make a small PDF file in Linux?
I need to include 7KB of text and repeat one PNG image 6 times.
Manually or programatically. I'll take whatever I can get at this point.
PDF Spec suggests PNG is supported?
PNG isn't supported per se; PDF allows embedding JPEG images as-is, but not PNG images. PDF does borrow a set of features of the PNG format, however.
rinohtype (full disclosure: I'm the author) tries to embed as much as possible from PNG images as-is into the PDF. This does involve some bit-juggling to separate the alpha channel from the color data for example, but no reencoding of the image is performed. It does not (yet) support interlaced PNGs.
rinohtype should be able to do what you want to achieve. But please note that it currently is in a beta stage, so you might encounter some bugs.
Even plain text PDF files are surprisingly large
To keep the PDF size as small as possible, make sure not to embed/subset any of the fonts. Use only the fonts from the base 14 PDF fonts which are provided by PDF readers.
What you want is certainly achievable. Regarding the image quality, I would recommend making your image twice the size that you want it to actually display at in the PDF to keep it looking sharp.
As to the size, I've just modified a test in my PDF writer module (WIP..) to include a 7.2K png, 200px x 70px, in a PDF twice and the PDF came out at 6.8K 8). There's not much text included, but more text will only add what it's worth + a small percentage.
You can see the module and original test here.. https://github.com/DoccaPDF/docca-pdf-writer/blob/master/src/tests/writer.js#L40
That test adds ~112K of images to the PDF and results in a 103K PDF.
Of course not all images are created equal so you milage may vary..
*the images are only actually added to the PDF once, but are displayed multiple time.

FlashAir: change the size of thumbnail images

Is it possible to control the thumbnail size from thumbnail.cgi? Or is this extracted from the EXIF thumbnail in the main image?
In the browser example (the last 2 images at the bottom of the last tutorial page) they suggest that different size files can be generated and downloaded
How is this achieved?
I was looking at LUA scripting on a file write, but not really sure where to start with that.
Any help much appreciated.

I need to reduce size of image? Can somebody assist me?

I have a 512x512 1.03 mb .ico picture and need to upload it to a website that only accepts pictures 1mb large(or smaller idk) Can somebody help me and tell me a way to reduce the size of the image.
You can either compress/reduce the filesize of the icon (I recommend using ImageMagick to do this, you can download it here), or you can make the dimensions smaller. However, if you are putting an ico file on a website I recommend using a different image format, such as .png. You can convert it to png using a website called ConvertICO.
I hope this helps,
Santiago
Take a look on this page specially compression of ICO files and 4-bit option.

Resources