Hi,
Hi Diane,
will investigate this issue in details and will keep you updated on the status
of a correction. We
apologize for your inconvenience.
com.aspose.pdf.Document
doc = new
com.aspose.pdf.Document(“c:/pdftest/result.pdf”);<o:p></o:p>
System.out.println(doc.getPages().get_Item(1).getPageInfo().isLandscape());
doc.getPages().get_Item(1).getPageInfo().setLandscape(true);
doc.save("c:/pdftest/LandScapeOutput.pdf");
Hi,
Hi,
I am having a similar issue in .NET, does this issue exist for .NET as well?
Hi,
Do we have any SLA for this issue. We are moving to production soon. We need to see whether it can be fixed prior to that.
hapyfishrmn:I am having a similar issue in .NET, does this issue exist for .NET as well?
nielsenusa:Do we have any SLA for this issue. We are moving to production soon. We need to see whether it can be fixed prior to that.
The issues you have found earlier (filed as PDFNEWNET-36115) have been fixed in Aspose.Pdf for .NET 9.6.0.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
(4)
Hi Diane,
Document doc = new Document(“PdfWithText.pdf”);<o:p></o:p>
foreach (Page page in doc.Pages)<o:p></o:p>
{<o:p></o:p>
Aspose.Pdf.Rectangle r = page.MediaBox;<o:p></o:p>
double newHeight = r.Width;<o:p></o:p>
double newWidth = r.Height;<o:p></o:p>
double newLLX = r.LLX;<o:p></o:p>
//we must to move page upper in order to compensate changing page size (lower edge of the page is 0,0 and information is usually placed from the top of the page. That’s why we move lover edge upper on difference between old and new height.<o:p></o:p>
double newLLY = r.LLY + (r.Height - newHeight);<o:p></o:p>
page.MediaBox = new Aspose.Pdf.Rectangle(newLLX, newLLY, newLLX + newWidth, newLLY + newHeight);<o:p></o:p>
//sometimes we also need to set CropBox (if it was set in original file)<o:p></o:p>
page.CropBox = new Aspose.Pdf.Rectangle(newLLX, newLLY, newLLX + newWidth, newLLY + newHeight);<o:p></o:p>
}<o:p></o:p>
doc.Save(“36115.pdf”);<o:p></o:p>
in order to avoid this you can increase width proportionally and leave height intact as following:
Aspose.Pdf.Rectangle r = page.MediaBox;<o:p></o:p>
//new height the same<o:p></o:p>
double newHeight = r.Height;<o:p></o:p>
//new width is expanded proportionally to make orientation landscape (we assume that previous orientation is portrait)<o:p></o:p>
double newWidth = r.Height * r.Height / r.Width;<o:p></o:p>
Document doc = new Document(“PdfWithText.pdf”);<o:p></o:p>
Aspose.Pdf.Rectangle r = doc.Pages[1].Rect;<o:p></o:p>
PdfPageEditor ppe = new PdfPageEditor();<o:p></o:p>
ppe.BindPdf(“PdfWithText.pdf”);<o:p></o:p>
ppe.Zoom = (float)(r.Width / r.Height);<o:p></o:p>
ppe.PageSize = new Aspose.Pdf.PageSize((float)r.Height, (float)r.Width);<o:p></o:p>
ppe.Save(“36115-1.pdf”);<o:p></o:p>
We will share Java code for the purpose with you soon.
Best Regards,
Does the isLandscape (.NET) / setLandscape (Java) have any function for actually setting the orientation of the page?
hapyfishrmn:Does the isLandscape (.NET) / setLandscape (Java) have any function for actually setting the orientation of the page?Hi,Thanks for contacting support.Yes your understanding is correct. The property in .NET and method in Java perform same operation. Please try using our API's and the event of any further query, please feel free to contact.
Thank you for the update. I am using the latest build of 9.6 and tried your original response using the isLandscape() and found it not changing the document from portrait to landscape.
Hi,
Hi,
Hi Diane,
Document doc = new Document(“PdfWithText.pdf”);<o:p></o:p>
for (int pageCount = 1; pageCount <= doc.getPages().size(); pageCount++)
{
Page page= doc.getPages().get_Item(pageCount);
com.aspose.pdf.Rectangle r = page.getMediaBox();
double newHeight = r.getWidth();
double newWidth = r.getHeight() * r.getHeight() / r.getWidth();
double newLLX = r.getLLX();
//we must to move page upper in order to compensate changing page size (lower edge of the page is 0,0 and information is usually placed from the top of the page. That's why we move lover edge upper on difference between old and new height.
double newLLY = r.getLLY() + (r.getHeight() - newHeight);
page.setMediaBox(new com.aspose.pdf.Rectangle(newLLX, newLLY, newLLX + newWidth, newLLY + newHeight));
//sometimes we also need to set CropBox (if it was set in original file)
page.setCropBox(new com.aspose.pdf.Rectangle(newLLX, newLLY, newLLX + newWidth, newLLY + newHeight));
}
doc.save("36115.pdf");
Please feel free to contact us for any further assistance.
Best Regards,
Hi,
Hi Diane,
Document doc = new Document(myDir+“ipnut.pdf”);<o:p></o:p>
com.aspose.pdf.Rectangle r = doc.getPages().get_Item(1).getRect();
PdfPageEditor ppe = new PdfPageEditor();
ppe.bindPdf(doc);
ppe.setZoom((float)(r.getWidth() / r.getHeight()));
ppe.setPageSize(new com.aspose.pdf.PageSize((float)r.getHeight(), (float)r.getWidth()));
ppe.save(myDir+"output_ppe.pdf");
Please feel free to contact us for any further assistance.
Best Regards,