Too big for what? But yes, if you want compressed images you need do that
ahead of time when using itext. OR you can use a variety of software solution
to optimize the PDF after creation. (or now!) Why not just use one of them
instead of wasting your time and effort to build something???
Leonard
From: Benjamin Podszun [mailto:[email protected]]
Sent: Friday, December 07, 2012 12:55 PM
To: [email protected]
Subject: [iText-questions] Got an Image to insert into my PDF, need native
(System.Drawing.Image / java.awt.Image) back
Hi.
The core problem: Sometimes my PDFs are much too big. Like 20 MB for 5 pages.
It seems the culprit here are images that I add to/as pages, and in broken
cases like the one above the images seem to be uncompressed in the source and
won't be compressed by itext.
Searching the net turned me towards advice to make sure that the input file is
already (in my case) jped compressed. My solution for the size issue therefor
seems to be to create a (suitably) compressed jpeg first and feed that to itext
later.
Unfortunately the code is built around the idea of getting a
RandomAccessFileOrArray and more or less turning just that thing (a tiff with
multiple pages) into a PDF.
Pages might be compressed differently, I see no 'file global' way to handle the
conversion. I tried plugging some code into the "get me the page in the Tiff"
code:
Previously:
Image pageImage = TiffImage.GetTiffImage(imageData, pageIndex);
What I try now:
Image pageImage = TiffImage.GetTiffImage(imageData, pageIndex);
// Compress the image if it's including color and not yet a jpeg
if (pageImage.Bpc == 8 && !pageImage.IsJpeg())
{
// Need a way to get that pageImage in a format I can work with here
I could add a couple workarounds to still be able to grab the original backend
for the RandomAccessFileOrArray (imageData). But - that feels wrong.
pageImage allows me to access the RawData, but I've no idea what it contains
and my tries to feed that to a System.Drawing.Bitmap failed so far.
Is there a way to do the inverse of
Image.GetInstance(platformNativeImageInstance)?
My platform is .Net, but I'm reasonably good at java - so itext or itextsharp
shouldn't matter, I hope.
Thanks a lot for your time,
Ben
------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php