Edit PDF Resolution

Example requests & Code samples for GdPicture Toolkits.
Post Reply
PQSIK
Posts: 50
Joined: Wed Oct 21, 2009 7:26 pm

Edit PDF Resolution

Post by PQSIK » Wed Oct 21, 2009 7:42 pm

Hi All,
And before I start I'm new to this stuff

Can someone show me how to open a pdf file from a file, change the Resolution and save the changes in vb.net 2.0

I have

Code: Select all

Dim ImageID As Integer = Imaging1.CreateGdPictureImageFromFile(ThisFile.FullName)
           Imaging1.SetHorizontalResolution(ImageID, 200)
            Imaging1.SetVerticalResolution(ImageID, 200)
            Imaging1.SaveAsPDF(ImageID, ThisFile.FullName, True, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing)
            Imaging1.ReleaseGdPictureImage(ImageID)
I can see the file ceared date time change so its doing something.

Do I have to save it as a new pdf?

Thanks

PQSIK

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Edit PDF Resolution

Post by Loïc » Thu Oct 22, 2009 11:55 am

Hi,

Here the good way :D

Code: Select all

Dim oGdViewer As New GdViewer
Dim oGdPictureImaging As New GdPictureImaging
Dim GdPictureImage As Integer

oGdViewer.SetLicenseNumber("XXX") 'unlocking
oGdViewer.DisplayFromFile("c:\in.pdf") 'Openning the PDF

GdPictureImage = oGdViewer.PdfRenderPageToGdPictureImage(200, 1) 'Rendering the first page to Bitmap
Imaging1.SaveAsPDF(GdPictureImage, "c:\out.pdf", True, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing) 'Saving the bitmap as new PDF
 oGdViewer.ReleaseGdPictureImage(GdPictureImage)

oGdViewer.CloseDocument()

MsgBox("Done !")

Let me know if you need more assistance.

With best regards,

Loïc

PQSIK
Posts: 50
Joined: Wed Oct 21, 2009 7:26 pm

Re: Edit PDF Resolution

Post by PQSIK » Thu Oct 22, 2009 11:31 pm

Thanks for the code it works fine


The problem I have now is using GdPicture its not Thread safe with pdf's

and I have threads running for each folder that has images in them

I may have to change the way I'm doing this

Code: Select all

For Each binfo As BatchInfo In BList
            If binfo IsNot Nothing Then
                Dim di As New IO.DirectoryInfo(binfo.Path)
                If di.GetFiles().Length > 0 Then
                    Dim bm As New BatchManager(binfo)
                    Dim objThread As New Threading.Thread(AddressOf bm.RunBatch)
                    objThread.Start()
                    ListBox1.Items.Add(String.Format("Bartch {0} running", binfo.BatchClass))
                End If
            End If

BatchManager
if tif ConvertTifToPDF
if pdf ChangePDFResolution

        Next
I dont want to run the next batch after the previous one finishes

PQSIK

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest