Aspose pdf page scale

Hello,

Actually we’re using Aspose.Pdf for .Net to handle all our pdf documents. Now we need to scale down a document page and insert it into a new page with extra stamps.

Currently I try to convert the page to image and then add it in a new page, but then I found the image is no more recognisable as texts. How should I do to convert the image back?

Cheers,
Rui

@rui.jia0408

Aspose.PDF does not offer any feature to read images. However, you can add a page stamp in your PDF document instead of image stamp in order to achieve your requirements. In case you face any issue, please share your sample PDF document(s) with us. We will test the scenario in our environment and address it accordingly.

Hello,

Sorry I didn’t respond you in time but finally I found the PageStamp to resolve my issue. Then I found another issue when I try to add a aspose.pdf.image in a floating box, I can see the space of image(which means the width/height is kept), but the image is never showing.

What I do is to create a floating box, and then add textFragment and images, the text is displayed well, but not the image. And I have also tried to add the image in the page.paragraphs but it’s also not working. Do you have any details about this?

For your information, I followed this exemple to add my image.

Thanks,
Rui

@rui.jia0408

Would you please share your sample PDF document along with the code snippet that you have prepared to add text and image. We will test the scenario in our environment and address it accordingly.

Hello,

Please check the codes as below:

            Dim mNewPtoDoc As New Aspose.Pdf.Document()
            Dim mNewPage As Aspose.Pdf.Page = mNewPtoDoc.Pages.Add()

            Dim fragment As Aspose.Pdf.Text.TextFragment = New Text.TextFragment("Some texts")
            fragment.TextState.Font = Aspose.Pdf.Text.FontRepository.FindFont("Helvetica")
            fragment.TextState.FontSize = 8
            fragment.TextState.FontStyle = Aspose.Pdf.Text.FontStyles.Regular
            fragment.TextState.LineSpacing = 4

            Dim imageSt As Aspose.Pdf.Image = New Aspose.Pdf.Image() With {.File = "file path of my image"}

            Dim fb2 As New FloatingBox
            fb2.Width = 500
            fb2.Border = New Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 1, Aspose.Pdf.Color.Black)
            fb2.Paragraphs.Add(fragment)
            fb2.Paragraphs.Add(imageSt)

            newPage.Paragraphs.Add(fb2)
            mNewPtoDoc.Save("out put path of the pdf")

And for your information, I also tried to create the image by setting the imageStream, but it’s neither working. Can you help this?

Thanks,
Rui

@rui.jia0408

We added following lines to set image height//width in your code and image was displayed in the resultant PDF:

imageSt.FixWidth = 400;
imageSt.FixHeight = 200;

output.pdf (8.9 KB)

Please let us know in case you have further inquiry.

Thanks for your information.

Finally I found that this is due to the image used and it’s working properly when I tried another one.

@rui.jia0408

It is good to know that your issue has been resolved. Please keep using our API and in case of any further assistance, feel free to create a new topic.