We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Width and height aren't that show

Hello,
I'm using the PDF library to insert seal image in differents pdf files that contain blueprints.
Use the page width and height to set seal position. The page orientation is set on portrait but the viewer show in landscape.

The problem is the width property is less than the height property, it's the opposite and some images aren't inserted.

How can i get the width and height that really show me the viewer?

Attach a sample pdf file


Attachment: Pruebas_(2)_b5300f3e.rar

3 Replies

IJ Irfana Jaffer Sadhik Syncfusion Team February 27, 2023 01:16 PM UTC

Use the page width and height to set seal position. The page orientation is set on portrait but the viewer show in landscape.

We have checked the reported behavior with the provided details on our end. We suspect that your resultant pdf document is rotated to 270 degrees and this makes the pdf preserve in the portrait orientation. We have created a simple sample and replicated a similar issue with the above scenario. We request you confirm this.

The problem is the width property is less than the height property, it's the opposite and some images aren't inserted.
Can you please share a simple sample with us? So that we can assist you further in this.




PP Pedro Palomino Aráoz March 21, 2023 06:32 PM UTC

Hello, sorry for the delay.

I attach an sample, I'm using Wisej, the problem is in first page, the image doesn't insert in the first page because the height, but in the third page is inserting very well.

Take the width and height like all the page are the same but some pages are show as landscape.


Attachment: InsertImageSample_16e91d65.rar


IJ Irfana Jaffer Sadhik Syncfusion Team March 22, 2023 01:50 PM UTC

On our further analysis, we found that your first page of the PDF document is rotated to 90 degrees. we have attached a workaround to achieve the correct bounds of the pdf to insert the image into the pdf document. Please try this on your end and let us know the result.

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/InsertImageSample-806468491

Code snippet to get corrected bounds:

Private Shared Function GetCorrectedBounds(ByVal page As PdfLoadedPage, ByVal bounds As RectangleF) As RectangleF

    Dim pagesize As SizeF = page.Size

    Dim rectangle As RectangleF = New RectangleF(bounds.X, bounds.Y, bounds.Width, bounds.Height)


    If page.Rotation = PdfPageRotateAngle.RotateAngle90 Then

        rectangle.X = pagesize.Height - (bounds.Y + bounds.Height)

        rectangle.Y = bounds.X

        rectangle.Width = bounds.Height

        rectangle.Height = bounds.Width

    ElseIf page.Rotation = PdfPageRotateAngle.RotateAngle270 Then

        rectangle.X = pagesize.Width - (bounds.X + bounds.Width)

        rectangle.Y = bounds.Y

        rectangle.Width = bounds.Height

        rectangle.Height = bounds.Width

    ElseIf page.Rotation = PdfPageRotateAngle.RotateAngle180 Then

        rectangle.X = pagesize.Width - (bounds.X + bounds.Width)

        rectangle.Y = pagesize.Height - (bounds.Y + bounds.Height)

        rectangle.Width = bounds.Width

        rectangle.Height = bounds.Height

    End If


    Return rectangle

End Function


We request you to try this on your end and let us know the result


Loader.
Up arrow icon