Print Page | Close Window

Not sure of how to work with loaded pdf file

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=1814
Printed Date: 06 Feb 26 at 7:55AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Not sure of how to work with loaded pdf file
Posted By: Carneno
Subject: Not sure of how to work with loaded pdf file
Date Posted: 21 Apr 11 at 7:07PM
Hello,
 
I'm developing a VB 6.0 printing program on an XP Pro, SP3 computer.

I want to load a PDF from a file, put some text on the page and print it using QuickPDF 7.24.

After doing this:
    QuickPDFResult = QuickPDFObject.LoadFromFile("C:\CoyneEDMS\CofAs\10300_081210C01_SUN2.pdf")
I look at the PageHeight and PageWidth and it shows 3230 and 2475.  I have no idea of what those numbers are.  I doubt if they are the 72 points per inch.
 
After using DrawText to put text onto the page and printing it, the text inserted prints so small that i needed a magnifying glass to read it.  I had to increase the text size to 48 to make it print a legible line of text about the size of a 12 point.
 
Does anybody know how to work with a loaded PDF file and use standard font sizes and standard page sizes?
 
Any help would be gratefully appreciated.
 
Thanks,
Tony


-------------
Stop The World, I want To Get Off.



Replies:
Posted By: Rowan
Date Posted: 22 Apr 11 at 11:21AM
Hi Tony,

The 3230 and 2475 sizes are likely correct. It's likely that the page size of your document is just quite big and thus the seemingly strange results with DrawText. The default measurement unit used in PDF is a point. More info http://help.quickpdflibrary.com/questions/125/what-is-a-point-typography - about points here . You can change the measurement unit to mm or inches using the SetMeasurementUnits function. 

If you upload your PDF somewhere and post a link we can check to see if the page size returned is correct.

Cheers,
- Rowan.


Posted By: Carneno
Date Posted: 22 Apr 11 at 1:22PM

Hello Rowan.

 

Thanks for your help.

 

One thing I forgot to mention is that the PDF I am working with was converted from a TIFF file using QuickPDF.  It's a two page document that prints on letter size paper.  Here is the code I used:

 

QuickPDFTiffImagePages = QuickPDFObject.GetImagePageCount("C:\Dataflow\TiffBase\BOLDUP1.TIF")

For i = 1 To QuickPDFTiffImagePages

QuickPDFDocumentID = QuickPDFObject.AddImageFromFile("C:\Dataflow\TiffBase\BOLDUP1.TIF", i)
QuickPDFTiffImageWidth = QuickPDFObject.ImageWidth
QuickPDFTiffImageHeight = QuickPDFObject.ImageHeight
QuickPDFResult = QuickPDFObject.SetPageDimensions(QuickPDFTiffImageWidth, QuickPDFTiffImageHeight)
QuickPDFResult = QuickPDFObject.DrawImage(0, QuickPDFTiffImageHeight, QuickPDFTiffImageWidth, QuickPDFTiffImageHeight)
            If Not i = QuickPDFTiffImagePages Then
                        QuickPDFResult = QuickPDFObject.NewPage
            End If
Next

QuickPDFResult = QuickPDFObject.SaveToFile("C:\CoyneEDMS\PDF\DeliveryTicket.pdf")

After conversion, the PDF has a height and width of 3296 and 2500.  I looked at the properties of the input TIFF file and it has the same measurements in pixels with a 300DPI.  So, I have to assume the numbers I am getting from QuickPDF after loading in the converted PDF file are pixels.

Should I continue to work with it that way?

 

If I change the measurement unit and work with it, then save the PDF after adding text to it, will it save it correctly so that it will print OK?

Where can I upload a file for you to look at it?  I can send you both the TIFF and PDF files.

 

Thanks for all of your help.

 

Tony



-------------
Stop The World, I want To Get Off.


Posted By: Carneno
Date Posted: 22 Apr 11 at 8:09PM
Rowan,
 
I tried setting the measurements unit to 0 and that did not help.  It still prints very tiny for a SetTextSize setting of 10.
 
I aslo tried setting the measurements unit to 2.
 
Should I just live with it and work with a pixel factor?  Or am I doing something wrong?
 
Thanks ,
Tony


-------------
Stop The World, I want To Get Off.


Posted By: Rowan
Date Posted: 23 Apr 11 at 9:46AM
Hi Tony,

If you email the files to us at support (at) quickpdflibrary.com then we can take a look at them.

Instead of the DrawImage function you might find the FitImage function is what you are looking for. If you image is really 3296 x 2500 then it won't fit onto a Letter size page, so you'll want to scale the image down. The FitImage function allows you to draw a scaled image in a specified area with the aspect ratio of the image being preserved.

Cheers,
- Rowan.


Posted By: Carneno
Date Posted: 23 Apr 11 at 4:29PM
Hello Rowan.
 
I sent the files to Andrew in customer service and he helped me create a formula to fix the problem.
 
Here is the code that Andrew helped me with to convert the TIFF images.

Private Sub Convert_TIFF_To_PDF(ByVal SavedPDFFile As String, ByVal LoadedPDFFile As String)
       
    QuickPDFTiffImagePages = QuickPDFObject.GetImagePageCount(LoadedPDFFile)
       
        For i = 1 To QuickPDFTiffImagePages
       
            If Not i = 1 Then
                QuickPDFResult = QuickPDFObject.NewPage
            End If
            QuickPDFResult = QuickPDFObject.SetOrigin(1)
            QuickPDFDocumentID = QuickPDFObject.AddImageFromFile(LoadedPDFFile, i)
            QuickPDFHorizontalResolution = QuickPDFObject.ImageHorizontalResolution
            QuickPDFTiffImageWidth = QuickPDFObject.ImageWidth / QuickPDFHorizontalResolution * 72
            QuickPDFTiffImageHeight = QuickPDFObject.ImageHeight / QuickPDFHorizontalResolution * 72
            QuickPDFResult = QuickPDFObject.SetPageDimensions(QuickPDFTiffImageWidth, QuickPDFTiffImageHeight)
            QuickPDFResult = QuickPDFObject.DrawImage(0, 0, QuickPDFTiffImageWidth, QuickPDFTiffImageHeight)
       
        Next
       
        QuickPDFResult = QuickPDFObject.SaveToFile(SavedPDFFile)
        QuickPDFResult = QuickPDFObject.RemoveDocument(QuickPDFObject.SelectedDocument)
End Sub
 
This works just fine for my purposes.
 
Thanks for all of your suggestions and help.
 
Tony


-------------
Stop The World, I want To Get Off.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk