Hi there
I have a number of pdfs supplied by our customer which are A0/A1 pdfs and I am using Aspose PDF to resize these images to A3 . When I look at new A3 sized PDF , the original content has been lost in the resized file.
This is a major issue and I am not sure if this is a bug in Aspose .PDF or whether I am using the wrong command
The version I am using is Apose PDF v22.11.0.0
Here is the function that I am calling passing in the source file name , papersize = 8 (A3)
I can send you the files if required , so please let me know which email to send those to.
private void ResizeDocument(string inputFileName, int paperSize, string watermarkText, string captionText)
{
try
{
bool bFoundPapersize = true;
PdfPageEditor pEdit = new Aspose.Pdf.Facades.PdfPageEditor();
using (Aspose.Pdf.Document doc = new Aspose.Pdf.Document(inputFileName))
{
pEdit.BindPdf(doc);
float capionFontSize = 12;
float watermarkFontSize = 12;
float headerTopMargin = 0;
for (int i = 0; i < doc.Pages.Count; i++)
{
// get the page size
var pageSize = pEdit.GetPageSize(i + 1);
PdfFileEditor pfe = new PdfFileEditor();
switch (paperSize)
{
case 127: //A0
case 261:
if (pageSize.IsLandscape)
{
pfe.ResizeContents(doc, new int[] { i + 1 }, Aspose.Pdf.Facades.PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A0.Height, PageSize.A0.Width));
}
else
{
pfe.ResizeContents(doc, new int[] { i + 1 }, Aspose.Pdf.Facades.PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A0.Width, PageSize.A0.Height));
}
capionFontSize = 12;
watermarkFontSize = 12;
headerTopMargin = 12;
break;
case 129: // "A1"
case 262:
if (pageSize.IsLandscape)
{
pfe.ResizeContents(doc, new int[] { i + 1 }, Aspose.Pdf.Facades.PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A1.Height, PageSize.A1.Width));
}
else
{
pfe.ResizeContents(doc, new int[] { i + 1 }, Aspose.Pdf.Facades.PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A1.Width, PageSize.A1.Height));
}
capionFontSize = 12;
watermarkFontSize = 12;
headerTopMargin = 12;
break;
case 66: // "A2"
case 263:
if (pageSize.IsLandscape)
{
pfe.ResizeContents(doc, new int[] { i + 1 }, PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A2.Height, PageSize.A2.Width));
}
else
{
pfe.ResizeContents(doc, new int[] { i + 1 }, PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A2.Width, PageSize.A2.Height));
}
capionFontSize = 12;
watermarkFontSize = 12;
headerTopMargin = 12;
break;
case 8: // "A3"
case 264:
if (pageSize.IsLandscape)
{
pfe.ResizeContents(doc, new int[] { i + 1 }, PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A3.Height, PageSize.A3.Width));
}
else
{
pfe.ResizeContents(doc, new int[] { i + 1 }, PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A3.Width, PageSize.A3.Height));
}
capionFontSize = 12;
watermarkFontSize = 12;
headerTopMargin = 12;
break;
case 9: // "A4"
case 265:
if (pageSize.IsLandscape)
{
pfe.ResizeContents(doc, new int[] { i + 1 }, Aspose.Pdf.Facades.PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A4.Height, PageSize.A4.Width));
}
else
{
pfe.ResizeContents(doc, new int[] { i + 1 }, Aspose.Pdf.Facades.PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A4.Width, PageSize.A4.Height));
}
capionFontSize = 12;
watermarkFontSize = 12;
headerTopMargin = 12;
break;
case 11: // "A5"
if (pageSize.IsLandscape)
{
pfe.ResizeContents(doc, new int[] { i + 1 }, Aspose.Pdf.Facades.PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A5.Height, PageSize.A5.Width));
}
else
{
pfe.ResizeContents(doc, new int[] { i + 1 }, Aspose.Pdf.Facades.PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A5.Width, PageSize.A5.Height));
}
capionFontSize = 12;
watermarkFontSize = 12;
headerTopMargin = 12;
break;
case 70: // "A6"
if (pageSize.IsLandscape)
{
pfe.ResizeContents(doc, new int[] { i + 1 }, Aspose.Pdf.Facades.PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A6.Height, PageSize.A6.Width));
}
else
{
pfe.ResizeContents(doc, new int[] { i + 1 }, Aspose.Pdf.Facades.PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A6.Width, PageSize.A6.Height));
}
capionFontSize = 12;
watermarkFontSize = 12;
headerTopMargin = 12;
break;
default:
bFoundPapersize = false;
break;
}
}
doc.Save(inputFileName);
pEdit.Close();
pEdit.Dispose();
}
}
catch (Exception ex)
{
}