We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Small images in headers&footers are magnified

<o:shapelayout v:ext=“edit”>
<o:idmap v:ext=“edit” data=“1”/>

Hi support,

Please note that small images in headers and footers are magnified. It is the same behavior as images being resized in a cell container. If no fix shall be provided for this, at least please specify if I can workaround the issue like this : if the image has the width smaller than the page width without its margins, that I must set the width&height for that image, in order to preserve original dimensions; if the image has the width bigger, that I will not do any processing.

Please advice,

Dear Milan,

Thanks for considering Aspose, I am a developer of Aspose.Pdf. I am not sure what the problem you are facing, if you give us more details and provide the files and codes you are using, we could investigate it better so that resolve the problem earlier.

As a matter of fact, if you want to resize the image in pdf file, you could use the codes like below which may help you workaround the issue:

img.IsScaled = true;
img.ImageScale = 0.6F;


Hi Emil.Hu,

Here is my code. I attach the image and output file also.

Pdf pdf1 = new Pdf();
Section sec1 = pdf1.getSections().add();
HeaderFooter header = new HeaderFooter(sec1);
Image imgX = new Image(sec1);
imgX.getImageInfo().setFile(“C:/Documents and Settings/Desktop/littlefrog.jpg”);
sec1.getParagraphs().add(new Text(sec1, “This is the original image :”));
FileOutputStream out = new FileOutputStream(new File(“C:/Temp/ImageInFooter.pdf”));


Hello Milan,

I’ve tested the issue and I am able to notice that the image in header/footer section is being scaled. We are looking into the details of this matter and will keep you updated with the status of correction.

We apologize for your inconvenience.

Hi, milan,

I have logged this issue(PDFJAVA_7118) in our bug trackle system. We will give you a hotfix in the next two weeks.

Thank you for using our product.

Hello Milan,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

As a workaround you can use table in Header section and set table’s ColumnWidth. Please try using the following code snippet.


//Create pdf document

Pdf pdf = new Pdf();

//Add a section into the pdf document

Section sec1 = pdf.getSections().add();

HeaderFooter Header = new HeaderFooter(sec1);

//Set the header of odd pages of the PDF document


//Set the header of even pages of the PDF document


//Create an image object in the section

com.aspose.pdf.elements.Image img1 = new com.aspose.pdf.elements.Image(sec1);

//Set the path of image file


// Create a new table

Table pdfTable = new Table(sec1);

//Set the column widths of the table


// Add row to Table

Row headerRow = pdfTable.getRows().add();

// create a cell with image object

Cell c = new Cell(pdfTable, img1);

//Add 1st cell in the row


// add the text to Paragraphs collection of Header


FileOutputStream out = new FileOutputStream(new File("d:/pdftest/HeaderShowing_Image.pdf"));


I've test it with Aspose.Pdf for Java which has already been shared at 156384 against "Header&Footer doesn't resize to fit content" or also can be accessed at 159605, please try using it, and in case of any further query, feel free to contact.