PDFsharp & MigraDoc Forum
https://forum.pdfsharp.net/

Does someone write the code for exporting png image?
https://forum.pdfsharp.net/viewtopic.php?f=2&t=2022
Page 1 of 1

Author:  wmj [ Thu May 17, 2012 8:47 am ]
Post subject:  Does someone write the code for exporting png image?

static void ExportAsPngImage(PdfDictionary image, ref int count)
{
int width = image.Elements.GetInteger(PdfImage.Keys.Width);
int height = image.Elements.GetInteger(PdfImage.Keys.Height);
int bitsPerComponent = image.Elements.GetInteger(PdfImage.Keys.BitsPerComponent);

// TODO: You can put the code here that converts vom PDF internal image format to a Windows bitmap
// and use GDI+ to save it in PNG format.
// It is the work of a day or two for the most important formats. Take a look at the file
// PdfSharp.Pdf.Advanced/PdfImage.cs to see how we create the PDF image formats.
// We don't need that feature at the moment and therefore will not implement it.
// If you write the code for exporting images I would be pleased to publish it in a future release
// of PDFsharp.
}

(1) Does someone write the code for exporting png image?

(2) When export image, "/DCTDecode" and "/FlateDecode" are used. Are they used to differentiate image type? And how are they written into PDF?

switch (filter)
{
case "/DCTDecode":
ExportJpegImage(image, ref count);
break;

case "/FlateDecode":
ExportAsPngImage(image, ref count);
break;
}

Thanks.

Author:  () => true [ Thu May 17, 2012 5:16 pm ]
Post subject:  Re: Does someone write the code for exporting png image?

wmj wrote:
And how are they written into PDF?
The code that adds them to the PDF is included with PDFsharp. And all details are in Adobe's PDF reference.

/DCTDecode indicates JPEG images
/FlateDecode indicate LZW compressed data => with /DCTDecode: "zipped" JPEG, without /DCTDecode: "zipped" PDF bitmap

See also:
http://stackoverflow.com/q/10024908/1015447
viewtopic.php?f=2&t=1944&hilit=%2FFlateDecode
viewtopic.php?f=2&t=1053&hilit=%2FFlateDecode

Author:  wmj [ Fri May 18, 2012 4:41 am ]
Post subject:  Re: Does someone write the code for exporting png image?

() => true wrote:
wmj wrote:
And how are they written into PDF?
The code that adds them to the PDF is included with PDFsharp. And all details are in Adobe's PDF reference.

/DCTDecode indicates JPEG images
/FlateDecode indicate LZW compressed data => with /DCTDecode: "zipped" JPEG, without /DCTDecode: "zipped" PDF bitmap

Thanks.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/