Aspose.Pdf.Generator.Pdf fail to generate pdf file using Gif image containing a hashtag(#) in its file name

Hi,

I’ve found a issue. Can anyone confirm this?

Below is official code example you could find in this web page:

//Instantiate a Pdf object by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
//Create a section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
//Create an image object in the section
Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(sec1);
//Add image object into the Paragraphs collection of the section
sec1.Paragraphs.Add(image1);
//Set the path of image file
image1.ImageInfo.File = “C:/Images/aspose.jpg”;
Here, if you use an Gif image file containing a hashtag(#) in its file name, like “#.gif”, then you’ll got an empty test.pdf (0KB) as output.
Weirdly, jpeg image, e.g., “#.jpeg”, does not have this problem.
//Set the type of image using ImageFileType enumeration
image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;
//Set image title
image1.ImageInfo.Title = “JPEG image”;
//Save the Pdf
pdf1.Save(“d:\temp\test.pdf”);

Thanks,
Jake

Hi Jake,


Thanks for contacting support.

I have tested the scenario using new Document Object Model (DOM) of Aspose.Pdf namespace and I am unable to notice any issue. Also please note that new DOM approach is recommended approach for documentation creation as well as manipulation. Can you please try using following code snippet and in case you still face any issue, please share your input image file so that we can test the conversion in our environment.

We are sorry for your inconvenience.

[C#]

//
load source HTML file
<o:p></o:p>

Document doc = new Document();

// add page to pages collection of Document instance

doc.Pages.Add();

// create Image object

Aspose.Pdf.Image image = new Aspose.Pdf.Image();

// specify Image file path

image.File = "c:/pdftest/PageLayout##.gif";

// add image to paragraphs collection of first page

doc.Pages[1].Paragraphs.Add(image);

// save output as PDF

doc.Save(“c:/pdftest/GIF_Converted.pdf”);

Hi Nayyer,

Thanks very much for your reply.
I’ve tried the DOM approach you sugessted and it works.

However, I didn’t notice any words mentioning that DOM approach is recommended approach or something like that, when I go through the Aspose.Pdf.Generator’s documentation. That is really confusing.

Should I abort using Generator approach totally and turn to DOM approach?
Is DOM approach more robust and feature-rich than Generator approach?

As for the image file you’ve requested, I think it’s not relavent, since
it’s a file name, not the content that causes the issue.

BTW, are there any offline documentation such as API reference downloadable?

Thanks,
Jake





Hi Jake,


We have shared the words to try migrating to new DOM approach in some of our recent blogs and from time to time, we keep suggesting our customers to migrate to new DOM approach as all the new features and enhancements are being introduced in this namespace.

Furthermore, the new DOM approach provides all the features present in legacy Aspose.Pdf.Generator approach plus it also offers the capabilities to manipulate existing PDF files, which is not supported by legacy Aspose.Pdf.Generator approach.

Now concerning to offline API Reference, you can find Aspose.Pdf.chm file under Help folder of Aspose.Pdf for .NET installation directory. Should you have any further query, please feel free to contact.

Nayyer,

Thank you very much for your reply.

However, I’ve installed Aspose.Total, and I see no such chm file under intalled folders.

Thanks,
Jake

Hi Jake,


We will test the scenario and see why Aspose.Pdf.chm is not being installed when using Aspose.Total for .NET installer. However you can find the required artifact in Aspose.Pdf for .NET 10.1.0 (dll version) package and for your convenience, I have also attached the required file with this post.

Hi Jake,


Thanks for your patience.

I have downloaded Aspose.Total for .NET package from download section and as per my observations, Aspose.Pdf.chm is installed when I have tried installing Aspose.Pdf for .NET 10.2.0 from this package.

Please try downloading/using the latest release and in case you still face any issue or you have any other query, please feel free to contact.