When I try to print to PDF file from Gembox.Spreadsheet using Gembox vs using Microsoft’s print to PDF, there is a major difference in layout. From what I see, the Worksheet’s built in Margin and Print options is already read and applied to the PDF print
Is this normal and must be accepted or there are configs to solve this situation?
Microsoft Excel Print To PDF
Gembox Save to PDF
The code in action
var resultExcel = ExcelFile.Load("D:\\TemplateExcel.xlsx");
// Do small value manipulation
resultExcel.Save("D:\\Tempfile.xlsx");
resultExcel.Save("D:\\TempPdf.pdf",new GemBox.Spreadsheet.PdfSaveOptions());
The TemplateExcel file in action
Side topic, I am loading the “printed” PDF to GemBox.Pdf like so
resultExcel.Save(resultExcelStream, SaveOptions.PdfDefault);
using var document = PdfDocument.Load(resultExcelStream);
for (var i = 0; i < document.Pages.Count; i++)
{
// I would like to shift the Excel table to the right. Is it possible?
// document.Pages[i].Transform.Translate(100,100); // does nothing
}
Hi,
The following is a screenshot of the print preview for your workbook in the LibreOffice Calc application:
As you can see, it can fit more content than Microsoft Excel.
Anyway, I’m afraid that different rendering engines may result in paginating and rendering the content differently.
Regards,
Mario
Thank you Mario. Can you help me to take a look at another question on reply #2?
Try something like this:
for (var i = 0; i < document.Pages.Count; i++)
{
var elements = document.Pages[0].Content.Elements;
var group = elements.Group(elements.First, elements.Last);
var transform = group.Transform;
transform.Translate(100, 100);
group.Transform = transform;
}