PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 10:50 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Wed Jan 13, 2016 3:53 pm 
Offline

Joined: Tue Feb 12, 2013 1:51 pm
Posts: 2
Hi,

I've been asked to try and debug an app that i didn't write. The app converts TIF's to PDF's however I have a scenario where one works and the other doesn't, i'm wondering if it has anything to do with the Bit Depth but can find nothing in the documentation about this. The TIF with a bit depth of 1 works but a it Depth of 8 doesn't, not that I know what that means !

Source TIF's

http://www.bill-brown.com/images/116953726.tif
http://www.bill-brown.com/images/116769530.tif

PDF's Produced

http://www.bill-brown.com/images/116953726-works.pdf
http://www.bill-brown.com/images/116769530-failed.pdf

And here's the Code....

Code:
    Dim FN As String
    Dim document As New PdfDocument
    Dim docImage As Image
    Dim dimension As FrameDimension
    Dim page As PdfPage
    Dim pdfImage As XImage = Nothing
    Dim graphics As XGraphics = Nothing

          FN = txtTIFLocation.Text & DataRowView("FileName").ToString & ".tif"
          docImage = Image.FromFile(FN)
          dimension = New FrameDimension(docImage.FrameDimensionsList(0))
          page = New PdfPage

          pdfImage = XImage.FromGdiPlusImage(docImage)

          page.Height = pdfImage.PointHeight
          page.Width = pdfImage.PointWidth
          document.Pages.Add(page)
          docImage.SelectActiveFrame(dimension, 0)
          graphics = XGraphics.FromPdfPage(page)
          graphics.DrawImage(pdfImage, 0, 0)

          page.Close()
          page = Nothing
          docImage.Dispose()
          docImage = Nothing
          graphics.Dispose()
          graphics = Nothing
          pdfImage.Dispose()
          pdfImage = Nothing


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 13, 2016 4:09 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
Hi!

The file that fails is a JPEG file, not a TIFF file. Try your code under XP, most likely it will work.
There is a bug in Windows and some grayscale JPEGs get messed up.

You should call "XImage.FromFile(FN)" instead of "Image.FromFile(FN)". And you should try the latest PDFsharp version 1.50 beta 3.
Then it should also work with Windows 7, 8.1, and 10.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 13, 2016 5:24 pm 
Offline

Joined: Tue Feb 12, 2013 1:51 pm
Posts: 2
Thanks for quick reply Thomas, not sure what you mean by "The file that fails is a JPEG file, not a TIFF file" as for sure I'm reading in a TIF file, no jpeg's in sight !

I'll try the beta version though...


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 13, 2016 8:13 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 909
Location: CCAA
stevejebson wrote:
Thanks for quick reply Thomas, not sure what you mean by "The file that fails is a JPEG file, not a TIFF file" as for sure I'm reading in a TIF file, no jpeg's in sight!
Open the "TIFF" file with Wordpad or a hex editor and you will see the "JFIF" file header.

Try downloading "116769530.tif " with Internet Explorer 11 and it will prompt to save as "116769530.jpg".
It is a renamed JPEG file, not a TIFF file. I see the TIF extension, but no TIFF in sight (neither inside).

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 46 guests


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 post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group