Cropping a pdf but not getting right area

I am using aspose.pdf for cropping pdf from a region. following code I have used for cropping the pdf

Document document = new Document(AppDomain.CurrentDomain.BaseDirectory + “A1.pdf”);
PageCollection coll = document.Pages;
Aspose.Pdf.Rectangle pageRect = new Aspose.Pdf.Rectangle(30, 0, 690, 600);
document.Pages[1].CropBox = pageRect;
document.Save(AppDomain.CurrentDomain.BaseDirectory + “A2.pdf”);

in pdf rectangle I am passing values as
llx=left margin;
lly=margin from bottom
urx=width of article
ury=height of article

but not getting right area but converting pdf to html using aspose with same value getting the right article.
I don’t know I am doing something wrong or problem in this function.

Please help me
waiting for your reply

Hi there,


Thanks for your inquiry. We will appreciate it if you please share your sample input/output documents here. We will look into it and guide you accordingly.

We are sorry for the inconvenience caused.

Best Regards,

Thanks for quick reply

I have attached my input and output.
input pdf file is main from where I Have cropped the article. Hindustan image shows the highlighted article which I tried to crop and output image is what I got as output.
I have taken
llx=39
lly=683
urx=654
ury=452

Hi Devinder,


Thanks for your feedback. Please note Aspose.Pdf page origin is left bottom(0,0), so you need to to reset the article coordinates as following. Hopefully it will help you to resolve the issue.

Document document = new Document(myDir

  • “HindustanTime.pdf”);<o:p></o:p>

PageCollection coll = document.Pages;

Aspose.Pdf.Rectangle rect = document.Pages[1].Rect;

Aspose.Pdf.Rectangle pageRect = new Aspose.Pdf.Rectangle(20, 671, 693, 1125);

document.Pages[1].CropBox = pageRect;

MemoryStream ms = new MemoryStream();

document.Save(myDir+"A2.pdf");


Please feel free to contact us for any further assistance.


Best Regards,

Thanks for reply


I have one more question
I assume following
llx = margin from left
lly = margin from bottom
urx = width of article
ury = height of article

can you tell me what is actually llx,lly,urx and ury

Thanks in advance

Hi Devinder,


Thanks for your feedback. Please note as stated above page origin in Aspose.Pdf is left bottom of page. So the coordinates would be as following.

llx(lower left x coordinate)=margin from left.
lly(lower left y coordinate)=margin from bottom(bottom of rectangle)
urx(upper right x coordinate)=width of article
ury(upper right y coordinate)=margin from bottom of upper boundary of article.

For example A4 size page dimensions are(8.672x11.6972) so its rectangle coordinates would be from left bottom of page as following.

llx=0
lly=0
urx=594.72
ury=841.68

Hopefully it would help you to understand the rectangle coordinates.

Best Regards,

Thanks for your explanation.

I am cropping article with this it is working fine when article is in left side if I am cropping article from right then not getting article properly. I have already sent you one pdf please explain how I will extract the right most article.

Thanks And Regards
Devinder

Hi Devinder,


Can you please share the code snippet which can help us in replicating the issue at our end. We are sorry for this inconvenience.