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

Free Support Forum - aspose.com

Header not working for all formats

Hi Team,

i tried header food example but it is not working on all the formats. our business requirement is to have left header with some information about the diagram but it doesn’t work in all the formats. please see the below code sample for the same and attached Drawing1.vsdx fileDrawing1.zip (22.9 KB)

	String dataDir = Utils.getSharedDataDir(ManageHeadersandFooters.class) + "HeadersFooters/";
	String licenseFileDir = Utils.getSharedDataDir(ManageHeadersandFooters.class);
	String licenseFile = licenseFileDir+"Aspose.Diagram.lic";
	com.aspose.diagram.License license = new com.aspose.diagram.License();

	// call the diagram constructor to a load Visio diagram
	Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx");

	// add page number at the right corner of header

	// set text at the center
	diagram.getHeaderFooter().setHeaderCenter("Center of the header");

	// set text at the left side
	diagram.getHeaderFooter().setHeaderLeft("Left of the header");

	// add text at the right corner of footer
	diagram.getHeaderFooter().setFooterRight("Right of the footer");

	// set text at the center
	diagram.getHeaderFooter().setFooterCenter("Center of the footer");

	// set text at the left side
	diagram.getHeaderFooter().setFooterLeft("Left of the footer");

	// set header & footer color

	// set text font properties

	// save Visio diagram
	diagram.save(dataDir + "EditConnectorGeometry_Out.pdf", SaveFileFormat.PDF);


We have tested the scenario in our environment and were able to notice that header/footer was not present in the output PDF, PNG and HTML formats. However, we are further checking it and will get back to you soon with our feedback.

Hi @asad.ali, do we have any ETA on the same? if it will take more than this week time then can you please help me put the text box in the top left header with some information in it. we have a demo coming monday next week and we have to show some information. also we need this text to be printed in all the formats.


We have noticed that there is an issue with the API that it was not preserving header/footer while exporting diagram to other file formats. We have logged an issue as DIAGRAMJAVA-50701 in our issue tracking system for it and will further work over its fix. Please spare us some time.

You may please use following code snippet to add text inside a diagram. You can please change/adjust the values of PinX and PinY in order to position the text as per your desire:

com.aspose.diagram.Diagram diagram = new com.aspose.diagram.Diagram(dataDir + "Drawing1.vsdx");

double PinX = 1, PinY = 1, Width = 1, Height = 1;
String text = "Test text";
// add text to a Visio page
diagram.getPages().getPage(0).addText(PinX, PinY, Width, Height, text);
// save diagram
diagram.save(dataDir + "InsertTextShape_out.vsdx", SaveFileFormat.VSDX);

Hi @asad.ali,
I tried the code you provided. it works with visio format but as soon as you will try with pdf or any other format this code throws a nullpointerexception.


Please reinitialize Diagram object with saved Diagram and then save it to any other format like following:

diagram.save(dataDir + "ditConnectorGeometry_Out.vsdx", SaveFileFormat.VSDX);
diagram = new com.aspose.diagram.Diagram(dataDir + "ditConnectorGeometry_Out.vsdx");
com.aspose.diagram.PdfSaveOptions options = new com.aspose.diagram.PdfSaveOptions();
diagram.save(dataDir + "output.pdf", options);

Thanks @asad.ali, what is the status of header footer issue with all the formats? I am asking because we have a demo coming next week with VP’s and i wanted to showcase this feature of aspose to them. Its not mandatory but it is good to have feature so dont stretch your self but if i can get an idea about estimated time atleast i can pass this information to the management.


We would like to share with you that the ticket DIAGRAMJAVA-50701 is expected to be resolved in Aspose.Diagram for Java 20.8 which will release next month (August 2020). We will send you a notification as soon as the release is available and ticket is resolved.

Thanks @asad.ali, I will wait until this feature comes in next release.


Sure, we will notify you as soon as the feature is available.

Thanks @asad.ali

Our demo went well and now we are going to buy the permanent license soon.
Thanks for all your support on this POC.

Thanks & Regards,
Jitendra Shrivastava


Thanks for choosing our API.

Please let us know in case you need further assistance while using the API.

The issues you have found earlier (filed as DIAGRAMJAVA-50701) have been fixed in Aspose.Diagram for Java 20.8.

Hello Team,

I have tried to add the header and footer in the “VSDX” file in asp.net c#. The code which is given on https://docs.aspose.com/diagram/net/working-with-headers-and-footers/ working fine without error. But in the output file, I am not able to see any header or footer added. I have also checked the file which is uploaded on GitHub and still, I am not able to see the header and footer in that file as well.

Please, look into this issue asap and let me know. Does this work with a specified version of the Visio application?



Would you please make sure that you are using the API with a valid license or a 30-days free temporary license? In case you are still facing the issue, please let us know.