PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index PDFsharp - moved to http://forum.pdfsharp.net/
Please visit the new PDFsharp forum at http://forum.pdfsharp.net/
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Extract TIF from PDF

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index -> Support - moved to http://forum.pdfsharp.net/
View previous topic :: View next topic  
Author Message
Banjo



Joined: 25 Feb 2009
Posts: 2

PostPosted: Wed Feb 25, 2009 2:02 pm    Post subject: Extract TIF from PDF Reply with quote

Hi guys,

We have a PDF file that contains embedded tif images. We need to extract these and save them back into a tif file.

We have it narrowed down to the image element passed to this function:

Code:
static void ExportImage(PdfDictionary image, ref int count)
{
   string filter = image.Elements.GetName("/Filter");
   switch (filter)
   {
      case "/DCTDecode":
         ExportJpegImage(image, ref count);
         break;
      case "/FlateDecode":
         ExportAsTifImage(image, ref count);
         break;
   }
}


The ExportJpegImage function works fine using a BinaryWriter object to dump the jpeg file out. This is what I currently have for the Tif function:

Code:
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);

   byte[] stream = image.Stream.Value;

   MemoryStream memStream = new MemoryStream(stream, 0, stream.Length, true, true);
   Bitmap MyBitmap = new Bitmap(memStream, true);
   MyBitmap.Save("C:\\temp\\texttographic.tif", System.Drawing.Imaging.ImageFormat.Tiff);

}


This fails trying to create the bitmap object. System.ArgumentException is thrown with additional information of "Invalid Parameter Used".

Can anyone advise on how to save out tifs? Am I on even vaguely the right track?
Back to top
View user's profile Send private message
Banjo



Joined: 25 Feb 2009
Posts: 2

PostPosted: Mon Mar 02, 2009 10:08 am    Post subject: Reply with quote

ok, I've found the stuff in the samples that says there's a custom internal format that would need to be worked with to export the tiff image.

Is there anywhere that details this format?
Back to top
View user's profile Send private message
Thomas Hoevel



Joined: 16 Oct 2006
Posts: 387
Location: Cologne, Germany

PostPosted: Mon Mar 02, 2009 4:24 pm    Post subject: Reply with quote

PDFsharp contains code that creates the PDF format from GDI+ images.
See "void InitializeNonJpeg()" in PdfImage.cs.

See the Adobe PDF documentation for all details.
Here's one for Acrobat 7 (9 MB approx.):
http://partners.adobe.com/public/developer/en/pdf/PDFReference16.pdf
_________________
Regards
Thomas Hoevel
PDFsharp Team
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index -> Support - moved to http://forum.pdfsharp.net/ All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group. Hosted by phpBB.BizHat.com


Start Your Own YouTube Clone

Free Web Hosting | Free Forum Hosting | FlashWebHost.com | Image Hosting | Photo Gallery | FreeMarriage.com

Powered by PhpBBweb.com, setup your forum now!
For Support, visit Forums.BizHat.com