Hi,
Hi Carol,
Hi,
Hi Carol,
Good afternoon,
Nadsy:
Good afternoon,I just wanted to add that I’m following this thread (albeit for the .NET version). We have a situation where a Word document is on an A4 papersize, but the margins are setup like a B5 (T:70.9, R:120.5, B:212.65, L:120.5), and we need to detect these margins in the generated PDF.I have tried several suggestions in the forum (such as using PageSettings (Words) before Saving to PDF and using PdfFileEditor (PDF) on the generated PDF), but none seem to work. The margins always come out as 72,90,72,90 if the papersize is A4. The only way I was able to detect different margins was if I distilled the PDF (using Acrobat) first.Are you able to provide a workaround sample for my scenario whilst we wait for a fix for the above?I am using version 17.2.0.0 of both Aspose.Words and Aspose.Pdf (.NET).Hi Nadaav,Thanks for contacting support.The issue reported in this thread is related to Aspose.Pdf for Java whereas you are facing problem while using Aspose.Pdf for .NET. Furthermore, we request you to please share your input files, so that we can test the scenario in our environment. We are sorry for your inconvenience.
Hi Nayyer,
Hi Nadaav,
Thanks for sharing sample file(s). I have tested the whole scenario at my end and observed that the generated PDF document shows different margin information that that of word. Moreover I have also tried to save your Word Document (AsposeTestWord.docx) as PDF from MS Word as well and checked the margin info of the saved PDF document. The document generated from MS Word also had different margin information. I am also attaching the generated document for your reference.
Please note that Aspose.Words API implements the same functionality as MS Word does which means if you convert a document using Aspose.Words API it will be almost similar as it was converted using Microsoft Word. So this behavior of the API is expected.
Furthermore I have tried to change the margin information of generated PDF document using following code snippet but I have noticed that change in margins was not reflected in the generated output.
Document document = new Document(dataDir + “AsposeTestWord.pdf”);
document.Pages[1].PageInfo.Margin.Top = 144;
document.Pages[1].PageInfo.Margin.Bottom = 144;
document.Pages[1].PageInfo.Margin.Right = 100;
document.Pages[1].PageInfo.Margin.Left = 100;
Therefore I have logged this issue as PDFNET-42376 in our issue tracking system for the sake of detailed investigation. We will further look into the details of this issue and keep you updated on the status of its resolution. Please be patient and spare us a little time. We are sorry for the inconvenience.
Best Regards,
Hi Asad,
Hi Nadaav,
Nadsy:
is there a way of tracking progress of a job with the job number you provided?
Hi,
Is there any update on PDFJAVA-36496
Regards,
Thanks for your inquiry.
After further investigating earlier logged issue we have found it as not a bug in the API. Please note that PageInfo
properties are used for PDF generation only (for convenience of API users). PDF format has not page margin as entity but for existing document, you can try to calculate what you need, by analysis such entities as Artbox
, BleedBox
, CropBox
, MediaBox
, TrimBox
and Rect
property.
Please, get more information and code snippets here: Get and Set Page Properties|Aspose.PDF for Java
Hi,
Attach is the pdf document but I am not sure how to calculate the margins since the values are same for the box objects.
ArtBox : Height = 832.0, Width = 682.0, LLX = 0.0, LLY = 0.0, URX = 682.0, URY = 832.0
BleedBox : Height = 832.0, Width = 682.0, LLX = 0.0, LLY = 0.0, URX = 682.0, URY = 832.0
CropBox : Height = 832.0, Width = 682.0, LLX = 0.0, LLY = 0.0, URX = 682.0, URY = 832.0
MediaBox : Height = 832.0, Width = 682.0, LLX = 0.0, LLY = 0.0, URX = 682.0, URY = 832.0
TrimBox : Height = 832.0, Width = 682.0, LLX = 0.0, LLY = 0.0, URX = 682.0, URY = 832.0
Rect : Height = 832.0, Width = 682.0, LLX = 0.0, LLY = 0.0, URX = 682.0, URY = 832.0
Can you please guide me what needs to be done to get the top, left,right and bottom margins.pdfresizer.com-pdf-crop.pdf (31.3 KB)
TestMargins.pdf (32.0 KB)
Regards,
Thanks for sharing your feedback.
We have logged an investigation ticket as PDFJAVA-38023 to investigate scenario with your shared PDFs. As soon as we make some significant progress towards resolution of the ticket, we will surely share with you. Please spare us little time.
We are sorry for the inconvenience.
We have investigated the logged ticket and found that for this particular document the ContentBBox
could be used. It returns the rectangle containing contents without visible margins.
Rectangle contentBox = pdfPage.calculateContentBBox();
System.out.println("LLX = " + contentBox.getLLX() + ", LLY = " + contentBox.getLLY() + ", URX = " + contentBox.getURX() + ", URY = " + contentBox.getURY());
System.out.println("left = " + (contentBox.getLLX() - pdfPage.getRect().getLLX()) + ", bottom = " + (contentBox.getLLY() -pdfPage.getRect().getLLY()) +
", right = " + (pdfPage.getRect().getURX() - contentBox.getURX()) + ", top = " + (pdfPage.getRect().getURY() - contentBox.getURY()));