Hello,
Hi Peter,
Thanks Awais.
Hi Peter,
Can you please share if you are generating MS Word files by converting PDF documents to DOCX format using Aspose.Pdf for .NET and also you are setting the page orientation/dimensions in PDF document instead specifying the information in MS DOCX file.
Hi Nayyer,
To your second question: I’m printing the Word-document via MS-Word to a system printer; not via the Aspose API.
The first question I can’t answer directly; I think I’m converting PDF to Word.
I use:
Aspose.Pdf.Document document = new Document();
document.Save(fileName, SaveFormat.DocX);
Within this Aspose.pdf.document, I set a page orientation, as mentioned before:
Aspose.Pdf.Page pageUren = document.Pages.Add();
[//pageUren.PageInfo.IsLandscape](https://pageuren.pageinfo.islandscape/) = true;
[//pageUren.PageInfo.Width](https://pageuren.pageinfo.width/) = Aspose.Pdf.Generator.PageSize.A4Width;
[//pageUren.PageInfo.Height](https://pageuren.pageinfo.height/) = Aspose.Pdf.Generator.PageSize.A4Height;
If you need more details, please let me know.
Hi Peter,
Thanks for sharing the details.
Do you face issues when printing MS Word files using Aspose.Words ? i.e. Extra page being printed or margin not being honored.
It appears that you have created PDF documents using Aspose.Pdf and have set the margin information which is being treated as 0 when viewing the MS Word file created by Aspose.Pdf in MS Word. If so is the case, then please share the complete code snippet to generate PDF file using Aspose.Pdf and in case you are manipulating any existing PDF file, please share the resource PDF document.
In order to change page orientation, you may consider using following suggestions. Please note Rotation property changes orientation of entire page including its contents. In order to change page size you can set MediaBox of the page in the following way.
Document doc = new Document("PdfWithText.pdf");
foreach (Page page in doc.Pages)
{
Aspose.Pdf.Rectangle r = page.MediaBox;
double newHeight = r.Width;
double newWidth = r.Height;
double newLLX = r.LLX;
//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.LLY + (r.Height - newHeight);
page.MediaBox = new Aspose.Pdf.Rectangle(newLLX, newLLY, newLLX + newWidth, newLLY + newHeight);
//sometimes we also need to set CropBox (if it was set in original file)
page.CropBox = new Aspose.Pdf.Rectangle(newLLX, newLLY, newLLX + newWidth, newLLY + newHeight);
}
doc.Save("36115.pdf");
Please note that in that case you can cut some contents of the document (because we decrease height)
in order to avoid this you can increase width proportionally and leave height intact as following:
Aspose.Pdf.Rectangle r = page.MediaBox;
//new height the same
double newHeight = r.Height;
//new width is expanded proportionally to make orientation landscape (we assume that previous orientation is portrait)
double newWidth = r.Height * r.Height / r.Width;
Other option is to use PdfPageEditor facade (it can apply zoom to page contents)
Document doc = new Document("PdfWithText.pdf");
Aspose.Pdf.Rectangle r = doc.Pages[1].Rect;
PdfPageEditor ppe = new PdfPageEditor();
ppe.BindPdf("PdfWithText.pdf");
ppe.Zoom = (float)(r.Width / r.Height);
ppe.PageSize = new Aspose.Pdf.PageSize((float)r.Height, (float)r.Width);
ppe.Save("36115-1.pdf");
Hi Nayyer,
Hi Peter,
Hi,
Hi Peter,Peter85:Hi,Another problem I’m facing:When I create a table with many rows, I want it to continue on the next page when it gets over a certain height.Thus, I check with :if (double.Parse(tableUren.GetHeight().ToString()) > 120) {(create new page, table etc)}However, from the moment I take the table height (tableUren.GetHeight()) , my cellstyling (font, padding etc) change.Creating table via:Aspose.Pdf.Table tableUren = new Aspose.Pdf.Table();tableUren.ColumnWidths = “5%”;tableUren.DefaultCellTextState.Font = FontRepository.FindFont(font);tableUren.DefaultCellTextState.FontSize = 8;tableUren.DefaultCellTextState.FontStyle = FontStyles.Regular;Adding row via : Aspose.Pdf.Row hourRow = tableUren.Rows.Add();I’ve added examples of document with and without the problem.Anyone got an idea?Thanks!
notice the same problem. For the sake of correction, I have logged this problem
as PDFNEWNET-39378 in our issue tracking system. We will further
look into the details of this problem and will keep you updated on the status
of correction. Please be patient and spare us little time. We are sorry for
this inconvenience.