Hi,support:
would you please demo me how to crop pdfpage on vb.net?
Thanks.
Here is a code sample of cropping a page using Aspose.Pdf with VB.Net
Public Sub Logic()
' Load the PDF document
Dim doc As New Document($"{PartialPath}_input.pdf")
' Get the first page
Dim page As Page = doc.Pages(1)
' Set the CropBox property
Dim cropRect As New Rectangle(50, 50, 400, 400)
page.CropBox = cropRect
' Save the modified document
doc.Save($"{PartialPath}_output.pdf")
End Sub
Here are the input and output files:
CroppingDocumentPages_input.pdf (263.3 KB)
CroppingDocumentPages_output.pdf (256.9 KB)
Thanks. I will have a try.
And another issue is that:
Could the API convert multipages pdf to mutilpages tiff file? if so, how to implement it?
Here is the code sample:
Public Sub Logic()
' Load the PDF document
Dim doc As New Document($"{PartialPath}_input.pdf")
Dim converter As New PdfConverter()
converter.Resolution = New Resolution(300)
converter.BindPdf(doc)
converter.StartPage = 1
converter.EndPage = doc.Pages.Count
converter.DoConvert()
converter.SaveAsTIFF($"{PartialPath}_VB_output.tiff")
converter.Dispose()
End Sub
Thansk, I will try it.
And, How to get the converting progress if the pdf has dozen of or over hundred pages?
I try it,and found some text will miss in the tiff output.
If you can provide for us the PDF and show what page number and text is missing I will create a ticket for the dev team.
Please refer to the attachments for check.Whatever convert pdf to jpg or tiff, some text miss will occur.
Input.pdf (3.5 MB)
OutputWithTextMissed.jpg (125.3 KB)
Can you tell me what version are you using?
I get an error when processing that document.
Maybe is because I am missing a font.
Do you have " Source Han Serif"?
You need that font installed in your machine.
The version used is v21.3.
My PC has no Source Han Serif font,but has Microsoft Sans Serif.
The fixed api in the later version should detect whether the font of text in pdf is missed in client pc, if so,the missed font should be replaced as Arial Unicode MS when converting to tif or jpg becase the "Arial Unicode MS " font has been installed in any pc, thus will avoid this issue.
I will suggest you to configure replace the font. Look for the documentation in .Net c# and translate it to VS. That is what I have been doing for you.
At the end of this documentation page show how to change a document font. In the section " Remove Unused Fonts from PDF File"
Thanks for your suggestion. That is to say: Looking for each char all through the pdf text,and tell whether the font of each character exists in the pc, if no,replace and set a new font for the char first. Finally do the convert pdf page to tiff/jpg process?
The other option is to install the font. Sometimes fonts like this one are not free and are more difficult to obtain. But sadly, you must have the font installed in the machine that processes the document.