PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
How to insert a picture in the PDF file only once https://forum.pdfsharp.net/viewtopic.php?f=2&t=3397 |
Page 1 of 1 |
Author: | riccardo [ Wed Jul 27, 2016 11:07 am ] |
Post subject: | How to insert a picture in the PDF file only once |
How to insert a picture in the PDF file only once and show it on all pages I saved a invoice of 10 pages without logo. After that i add to the invoice a jpg of 10Kb as logo. The result file size grows of 100Kb. But when I print my document (without use PDFSharp) on a pdf printer virtual driver such as BullZip, PrimoPDF, PdfFactory, the file size growns only by 10Kb regardless of the number of pages. Thanks |
Author: | Thomas Hoevel [ Wed Jul 27, 2016 11:16 am ] |
Post subject: | Re: How to insert a picture in the PDF file only once and sh |
Hi! You do not show any code and no PDF file. viewtopic.php?f=2&t=832 When using PDFsharp as intended, the image will be included only once, even if it is referenced on many pages. If you create a single XImage and use that on all pages then there will be no problems. |
Author: | riccardo [ Wed Jul 27, 2016 12:42 pm ] |
Post subject: | Re: How to insert a picture in the PDF file only once and sh |
Thomas Hoevel wrote: If you create a single XImage and use that on all pages then there will be no problems. This is probably my problem: I create view objects for each page I will try to reuse XImage objects Thank you very much again |
Author: | Thomas Hoevel [ Wed Jul 27, 2016 12:59 pm ] |
Post subject: | Re: How to insert a picture in the PDF file only once |
There shouldn't be duplicates either when the same filename is used for all XImage objects. BTW: do you get an increase of 50 kB for a document with 5 invoices? If not then maybe there is a different issue. |
Author: | riccardo [ Wed Jul 27, 2016 2:44 pm ] |
Post subject: | Re: How to insert a picture in the PDF file only once |
Thomas Hoevel wrote: There shouldn't be duplicates either when the same filename is used for all XImage objects. Unfortunately I create the image from a BITMAPINFO* (C++/CLI) //PDFSharp does not support 16bit Bitmap^ AdjustBitDepth(Bitmap^ image) { Bitmap^ newImage = nullptr; switch (image->PixelFormat) { case PixelFormat::Format16bppRgb555: newImage = image->Clone(System::Drawing::Rectangle(0, 0, image->Width, image->Height), PixelFormat::Format32bppRgb); break; case PixelFormat::Format16bppRgb565: newImage = image->Clone(System::Drawing::Rectangle(0, 0, image->Width, image->Height), PixelFormat::Format32bppRgb); break; case PixelFormat::Format16bppArgb1555: newImage = image->Clone(System::Drawing::Rectangle(0, 0, image->Width, image->Height), PixelFormat::Format32bppArgb); break; } if (newImage == nullptr) return image; delete image; return newImage; } //////////////////////////////////////////////////////////////////////////// XImage^ FromMetaRecord(BITMAPINFO* pInfo, BYTE* bitmapBytes) { Gdiplus::GpBitmap *bitmap = NULL; Gdiplus::DllExports::GdipCreateBitmapFromGdiDib(pInfo, bitmapBytes, &bitmap); System::Reflection::MethodInfo^ mi = Bitmap::typeid->GetMethod("FromGDIplus", System::Reflection::BindingFlags::Static | System::Reflection::BindingFlags::NonPublic); Bitmap ^image = (Bitmap^)mi->Invoke(nullptr, gcnew cli::array<Object^> { IntPtr(bitmap) }); image = AdjustBitDepth(image); XImage^ xImage = XImage::FromGdiPlusImage(image); return xImage; } I am studying a methods to compare BITMAP objects to reuse the same XImage Thomas Hoevel wrote: BTW: do you get an increase of 50 kB for a document with 5 invoices? Yes, its size grows proportional with page number and image size |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |