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

Free Support Forum - aspose.com

Re-using Xml ImageData

Is it possible to reference previous images in a following tag when using the BindXml method?


In the following example, the image data is included in the XML twice. I would prefer to only include it once and reference the first instance when including the image a second time.

// http://tango.freedesktop.org/CodeTangoSet
// 16x16/text-x-java-source.png
var base64icon = “iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABm” +
“JLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsSAAALEgHS3X78AAAA” +
“B3RJTUUH1woeEREP5xtJ/AAAAB10RVh0Q29tbWVudABDcmVhdG” +
“VkIHdpdGggVGhlIEdJTVDvZCVuAAACY0lEQVQ4y4WT3UuTURjA” +
“f2d7361mztBl1MwUajlMbcUKK6NAM6OL7kv6GyoQw+husQbh3x” +
“DUVdD3h6jgRYqWYmLm18TKspqJ4dKx+c736WIqzhk9cOCcB87v” +
"/B7O8yhScSIYCnTy/6hpbGhqz8gGQwExTTNjGYYhhmFILBYTwz" +
“AkGApIMBSoXn9XW39o72jJgGdv3c6PmWmO+iu5frWBu82htmAo” +
“sGaSBvCV+xERBBAREAGE4bEhshxZRGYiXL50hfsP7rUBKgPwfr” +
“A3w+Cg9xDbspw8evKQWCzG4uIi/yyhvPRw6tGUA6YIppj4fIeZ” +
“mvqCzWbDmZ1DS+vLzQGDH/thRX8+Os+379MYhoGIoGs2dF3D7z” +
“uWZmDZqFtaUkH0zwI/IxG8xXvZZRf0uc/k6Qb7Cwvp7utaqX4T” +
“g6GRAQAmJsNYv77h2aNuNOJYLYpPPcKyxUGpv4ZEbgV3mm/Hgb” +
“NpBl5PGV5PGUop9hQfwJGzE8sWF0lrNlbHDnJcBTjz8qk6foqa” +
“MzV2pdTrNIOR8Q9r+9r6W9TW3wJgyVhK/UBsgZlfEXredeM/ch” +
“TTNI0Mg535bnRNZ+733Fo+mUySSMRJJpPk5brw7PPQ19+bAOIZ” +
“BuMTYRwOB09ePKairIKC3QU4s50oIJFI0NmTGpnl5eU4cE7baD” +
“AWHudkZRWaVaPrbSfDo8PEE3F0Tcdut1NXXYcpwqvWl7bGa00D” +
“aQC328352gs8f/2UosIiSjxeXLkunE4n0WiU2blZwpNhRsdHAS” +
“6y2s/BUKADOL0KEgQsoCwKhUJEUEohCGIKmPTfaLh5BOAv2s0Q” +
“1/ZjUwcAAAAASUVORK5CYII=”;

var xmlDoc = new System.Xml.XmlDocument();
xmlDoc.AppendChild(xmlDoc.CreateElement(“Pdf”));
for(int i = 0; i < 2; ++i)
xmlDoc.DocumentElement
.AppendChild(xmlDoc.CreateElement(“Section”))
.AppendChild(xmlDoc.CreateElement(“Image”))
.AppendChild(xmlDoc.CreateElement(“ImageData”))
.InnerText = base64icon;
var pdf = new Aspose.Pdf.Pdf();
pdf.BindXML(xmlDoc, null);
pdf.Save(@“d:\pdftest\xml-imagedata.pdf”);

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

Sorry for a delayed response.

Well, I am afraid; this feature is not supported at the moment. However, I have created an issue in our issue tracking system with issue id: PDFNEWNET-33271 for our development team to check if it is possible to implement such a feature. Once they investigate / analyze and share their feedback, I will update you via this forum thread.

Sorry for the inconvenience,

Hello,


Is re-using the same image multiple times in the same PDF possible using the straight API? If so, can you point me to a simple example like the one I put together above, or can you adapt the sample above to do so using the API?

Thanks.

Hi Jed,

First of all I apologize for the delayed in response.

Kindly use the below mentioned code to reuse same imaged multiple time in the same PDF. Resultant file is also attaced for your analysis.

[C#]

Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image();
image1.ImageInfo.File = @"d:\pdffiles\aspose-logo.gif";
Aspose.Pdf.Generator.Segment seg1 = new Segment();
seg1.InlineParagraph = image1;
Aspose.Pdf.Generator.Pdf pdfConv = new Pdf();
Section sec1 = pdfConv.Sections.Add();
Aspose.Pdf.Generator.Table table1 = new Aspose.Pdf.Generator.Table();
sec1.Paragraphs.Add(table1);
Aspose.Pdf.Generator.Text text;
Aspose.Pdf.Generator.Segment newSeg;

for (int i = 0; i < 5; i++)
{
Aspose.Pdf.Generator.Row row1 = table1.Rows.Add();
text = new Text();
newSeg = new Segment(text);
text.Segments.Add(seg1);
row1.Cells.Add();
row1.Cells[0].Paragraphs.Add(text);
}

pdfConv.Save(@"d:\pdffiles\Image_in_Cell.pdf");

Please feel free to contact support in case you need any further assistance.

Thanks & Regards,