Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Thu Sep 20, 2018 8:31 pm

I have a PDF image that contains the entire webpage, including the part you can't view (when you scroll down).
I want to convert the PNG to a PDF. When I convert the image, the entire image appears on one page in the PDF and in really small print. I want the PNG to be normal page width and potentially multiple pages.

Here is the VB.Net code that creates the PDF:

Dim doc As New PdfDocument
Dim section As PdfSection = doc.Sections.Add
Dim page As PdfPageBase = doc.Pages.Add

Dim image As PdfImage = PdfImage.FromFile("C:\temp\PACER\CAPTURE\test.png")

Dim widthFitRate As Single = image.PhysicalDimension.Width / page.Canvas.ClientSize.Width
Dim heightFitRate As Single = image.PhysicalDimension.Height / page.Canvas.ClientSize.Height

Dim fitRate As Single = Math.Max(widthFitRate, heightFitRate)

Dim fitWidth As Single = image.PhysicalDimension.Width / fitRate
Dim fitHeight As Single = image.PhysicalDimension.Height / fitRate

page.Canvas.DrawImage(image, 30, 30, fitWidth, fitHeight)

doc.SaveToFile("C:\temp\PACER\CAPTURE\test.pdf")
doc.Close()

CodilisIT
 
Posts: 1
Joined: Mon Aug 13, 2018 7:58 pm

Fri Sep 21, 2018 9:44 am

Hello,

Thanks for your inquiry.
Please note that our Spire.PDF doesn't auto-split a large image to several when drawing the image to Pdf page, hence, there is no direct way to draw the large image into multiple Pdf pages. Please split your image into multiple images with the normal page width and height, then convert to Pdf of multiple pages with our Spire.PDF.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1536
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.PDF

cron