Question about TIFF and PDF

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Sean - Tracker, Chris - Tracker Supp, Tracker Supp-Stefan, Ivan - Tracker Software

Post Reply
WayneH
User
Posts: 85
Joined: Mon May 21, 2007 5:39 pm

Question about TIFF and PDF

Post by WayneH » Wed May 23, 2007 7:06 pm

I'm testing PDFXChange and creating PDFs,
but I'd like to convertmy completed PDFs to TIFF
(using a dll or com object - no printers, virtual or otherwise)

Can I use Image XChange to do this?

I'm using VB6, but I only see a demo for viewing. The ImagesTest.exe sample looks most promising but it's in C. Is there a VB version?

Thanks.

John - Tracker Supp
Site Admin
Posts: 8202
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Wed May 23, 2007 7:37 pm

Hi,

No - you will need to use the Viewer SDK to achive this - this is included in the PDF-Tools SDK for limited distribution.

Currently you have only the choice of using the Simple Viewer DLL SDK - but coming very shortly is the ActiveX of the full End user Viewer SDK - which may suit you better.

HTH
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

WayneH
User
Posts: 85
Joined: Mon May 21, 2007 5:39 pm

Post by WayneH » Wed May 23, 2007 7:46 pm

Do you have any examples of how to save a file from the Viewer SDK?

I've seen this to open a file: PXCV_ReadDocument....
and
PXV+CommonRenderParameters

But nothing to suggest exporting/saving as a different file format.

Thanks.

John - Tracker Supp
Site Admin
Posts: 8202
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Thu May 24, 2007 9:56 am

Hi Wayne,

Whilst this is entirely possible - we dont offer an example at this time as our main focus is on completion of the Viewer SDK ActiveX, The End User version and also Version 4 of all our products - so we are at this time at full stretch.

Essentially - the Simple Viewer SDK can render to a DIB section or HBITMAP. after this you can use Windows GDI+ to save to any format supported by Windows and there are copious notes on MSDN regarding GDI+ and its functionality.

Sorry we cannot help more at this time and we will look to add some sort of example in the 'nearish' future - but for now we just dont have the free time to add any extra demo app's.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

WayneH
User
Posts: 85
Joined: Mon May 21, 2007 5:39 pm

Post by WayneH » Thu May 24, 2007 12:15 pm

Perhaps you can take a quick look at what I have tried so far...

Code: Select all

Here's what I've done so far:

Public Declare Function PXCV_Init Lib "pxcview.dll" (ByRef doc As Long, ByVal Key As String, ByVal devcode As String) As Long
Public Declare Function PXCV_ReadDocumentW Lib "pxcview.dll" (ByVal doc As Long, ByVal Filename As String, ByVal Flags As Long) As Long
Public Declare Function PXCV_DrawPageToDC Lib "pxcview.dll" (ByVal doc As Long, ByVal page_num As Long, ByVal hDC As Long, renderparams As PXV_CommonRenderParameters) As Long
Public Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Public Declare Function DeleteDC Lib "gdi32" (ByVal hDC As Long) As Long
Public Type PXV_CommonRenderParameters
    wholepagerect As RECT
    drawrect As RECT
    Flags As Long
    rendertarget As Long
End Type
Public Const pxvrpf_Rotate_NoRotate As Long = &H0
Public Const pxvrpf_Rotate_Rotate90CW As Long = &H1
Public Const pxvrpf_Rotate_Rotate180 As Long = &H2
Public Const pxvrpf_Rotate_Rotate90CCW As Long = &H3
Public Const pxvrpf_UseVectorRenderer As Long = &H4
Public Const pxvrpf_RenderAsGray As Long = &H8
Public Const pxvrm_Viewing As Long = &H0
Public Const pxvrm_Printing As Long = &H1
Public Const pxvrm_Exporting As Long = &H2


Dim resolution As Long
Dim xTwip As Long
Dim pageW As Single
Dim pageH As Single
Dim rparams As PXV_CommonRenderParameters
	resolution = 300
	xTwip = 72
	pageW = 11
	pageH = 8.5
      With bi.bmiHeader
          .biBitCount = bitsout
          .biPlanes = 1
          .biCompression = BI_RGB
          .biSize = Len(bi.bmiHeader)
          .biWidth = pageW * resolution
          .biHeight = pageH * resolution
          .biSizeImage = (.biWidth * .biBitCount) + &H1F
          .biSizeImage = .biSizeImage And Not &H1F&
          .biSizeImage = .biSizeImage \ &H8
          .biSizeImage = .biSizeImage * .biHeight
      End With
	compDC = CreateCompatibleDC(0)
      mybitmap = CreateDIBSection(compDC, bi, DIB_RGB_COLORS, 0, 0, 0)
      hOldObj = SelectObject(compDC, mybitmap)      
      blank.Bottom = pageH * resolution
      blank.Top = 0
      blank.Left = 0
      blank.Right = pageW * resolution
'     rparams.drawrect = vbNull  ' entire page
      rparams.Flags = pxvrpf_Rotate_NoRotate Or pxvrpf_UseVectorRenderer 
      rparams.rendertarget = pxvrm_Exporting
      rparams.wholepagerect = blank
        
      status = PXCV_Init(pdf, "<YOUR REG KEY>", "<YOUR DEV CODE>")
      If (IS_DS_FAILED(status)) Then
          GoTo badfunc:
      End If
      status = PXCV_ReadDocumentW(pdf, StrConv("C:\junk.pdf", vbUnicode), 0&)
      If (IS_DS_FAILED(status)) Then
          GoTo badfunc:
      End If
      status = PXCV_DrawPageToDC(pdf, 0&, compDC, rparams) ''FAILS HERE WITH ERROR  -2112815103
      If (IS_DS_FAILED(status)) Then
          GoTo badfunc:
      End If

John - Tracker Supp
Site Admin
Posts: 8202
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Thu May 24, 2007 1:24 pm

Hi Wayne,

I have passed this back to our DEV team and just as soon as I get an answer - I'll be back

Thanks for your patience.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

John - Tracker Supp
Site Admin
Posts: 8202
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Thu May 24, 2007 2:07 pm

Hi Wayne,

This is what I have back :
The code is incomplete -- I have no definitions for some functions (CreateDIBSection for example) and structures (RECT, BitmapInfoHeader)

Please send a complete sample and we can then check/correct as appropriate.
thanks
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

WayneH
User
Posts: 85
Joined: Mon May 21, 2007 5:39 pm

Post by WayneH » Thu May 24, 2007 2:54 pm

I've attached the sample code.

Since I'm using a third-party ActiveX, expect portions to cause errors upon opening, which can be ignored.

Once open, run and click the "TIFF..." button

Thanks.
Attachments
PDFXCDemo.zip
(268.67 KiB) Downloaded 241 times

John - Tracker Supp
Site Admin
Posts: 8202
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Sat May 26, 2007 9:10 am

Hi Wayne,

Have located the problem in your code:

The issue is because in the PXV_CommonRenderParameters structure, the
fields wholepagerect and drawrect should not be a RECT structure but should be POINTERS to a RECT structure - this needs to be corrected and then all functions as it should.

Please see the attached updated source files.

HTH
Attachments
WayneView.zip
Updated source
(13.72 KiB) Downloaded 242 times
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

WayneH
User
Posts: 85
Joined: Mon May 21, 2007 5:39 pm

Post by WayneH » Mon May 28, 2007 3:19 pm

Thanks for the help so far.

I'm still running into a few issues when creating TIFF from PDFs.

1) If I use the DrawToDC method, the resulting image is rather low quality (lots of missing image) and the watermark from the PDF doesn't show up.

2a) If I instead use the DrawToDIB method, I get a better quality image, but still no watermark from the PDF.
2b) Also, the palette is "Min is Black" meaning palette 0 is black, not white as is normal. I have a method to resolve this but it doesn't work with DrawToDIB (it does work with DrawToDC)
(you can try this TIFF property viewer to see what I see: http://www.awaresystems.be/imaging/tiff ... iewer.html)

3) I tried using the Image XChange dll (i.e. PageCreateFromHBITMAP, etc) but have not been able to get it working. I was hoping to resolve issues 1 and 2 above by using this dll instead, but no luck.

I have uploaded another version of my sample code to illustrate the problems.

Again, thanks.
Attachments
PDFXCDemo.zip
(379.27 KiB) Downloaded 233 times

WayneH
User
Posts: 85
Joined: Mon May 21, 2007 5:39 pm

Post by WayneH » Thu Jun 07, 2007 1:04 pm

Can someone at Tracker please follow up with my last post?

Thank You.

John - Tracker Supp
Site Admin
Posts: 8202
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Thu Jun 07, 2007 5:21 pm

Hi wayne,

it is conceivable the watermarks issue may be ours - this wil need further investigateion when time allows - but I am afraid that will not be until V4 which as you know we are working on now.

with regards the other issues :

1. The PDF is landscape oriented, but you draw it as portrait. For sure it will be 'stretched'

2. TIFF corruption when DrawToDC is not our issue, but an issue with the library used to create the TIFF (the same with MinInBlack)

Also dont use the flag pxvrpf_UseVectorRenderer -- it can help improve quality -- GDI+ is good for high resolutions, but not for image sizes you are working with.

HTH
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

WayneH
User
Posts: 85
Joined: Mon May 21, 2007 5:39 pm

Post by WayneH » Thu Jun 07, 2007 5:50 pm

Thanks for responding...

1) I'm not sure what you mean about portrait vs landscape. The original image, the pdf, and both sample tiffs are all landscape. It's not being stretched at all.

2) The corruption being caused by the FreeImage library is seems strange to me since I use it for both DrawToDC and ToDIBSection.

3) I will turn off the UseVectorRenderer flag.
Since you mention image size, can you tell me when a good time to use it? What resolutions/sizes?

4) Are you able to address the other issue - Why I can't seem to get the IMG_ library to work?(look for this in the uploaded sample: "CANNOT GET THIS TO WORK AT ALL" ) ;)

Thank You.

John - Tracker Supp
Site Admin
Posts: 8202
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Fri Jun 08, 2007 8:12 am

Wayne,

if you really want us to get to grips with this and help - we need you to provide a basic application - that relies on no other 3rd party libraries/ActiveX's that you are unable to provide us directly.

Please provide :

A complete, basic project showing the problem without the any 3rd party ActiveX and works with the sample PDF/Images at 100%

Please provide the source and all reliant dll's and a compiled exe - Zipped -
Once we have this we will endeavour to assist and get this sorted as soon as possible

HTH
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

WayneH
User
Posts: 85
Joined: Mon May 21, 2007 5:39 pm

Post by WayneH » Fri Jun 08, 2007 12:50 pm

I have uploaded another version of the sample code which includes everything.

At this point, my issues are related only to creating a TIF from a PDF.

Thanks.
Attachments
PDFXCDemo2.zip
(861.57 KiB) Downloaded 249 times

John - Tracker Supp
Site Admin
Posts: 8202
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Tue Jun 12, 2007 8:30 am

Hi Wayne,

Pls see attached.
Attachments
2730.zip
Example app
(381.39 KiB) Downloaded 260 times
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

WayneH
User
Posts: 85
Joined: Mon May 21, 2007 5:39 pm

Post by WayneH » Tue Jun 12, 2007 1:06 pm

Hi -

I'm trying the code you supplied, and I am able to get tiff output now (thank you!)

However, the quality of the image is still a concern.
I tried using the Save Dialog so that I could try a variety of settings,
but the image is still not as clean as I would like.

I've uploaded 2 samples - one using ImageXChange and another using a different product. I would prefer to use ImageXChange if I can get the output to look as good.

The settings are the same for both methods of conversion:
junk.pdf
300x300 resolution
CCITT 4
8.5x11
1 bit
No Dither
(DrawToDIBSection was used with ImageXChange)

Also, I noticed that the new Viewer has been released - is the ActiveX included?

Thanks....
Attachments
sample_tifs.zip
(413.41 KiB) Downloaded 259 times

WayneH
User
Posts: 85
Joined: Mon May 21, 2007 5:39 pm

Post by WayneH » Wed Jul 18, 2007 3:18 pm

When you have a chance, can you please look into this?

There is a quality issue when creating TIFFs from PDF.

I'd prefer to use your solution, but to be honest, the competition seems to address this better.

Thank You.

Post Reply