Converting XPS to PDF not working

If you are a C/C++/C# developer and have any questions about using our products from your application here is the place to post them.
Post Reply
valvelink
Posts: 2
Joined: Wed Jan 28 2009

Converting XPS to PDF not working

Post by valvelink »

I am searching for a library capable of taking XPS documents generated by our application, and converting them directly to PDF documents. Your product looked promising, so I downloaded the developer trial just a few days ago and am now trying to do a simple test to see how well it works.

I have done 3 trials of varying types of XPS documents, and so far none of the resulting PDF documents are correct.

First, here is how I am doing the conversion (C#):

Code: Select all

acPDFCreatorLib.Initialize();
Stream xps = File.OpenRead("test.xps");
IacDocument doc = new IacDocument();
doc.Open(xps, "");
Stream pdf = File.Create("PdfDocument.pdf");
doc.Save(pdf, IacFileSaveOption.acFileSaveView);
acPDFCreatorLib.Terminate();
And here are the trials I conducted, and the results:

Trial 1
Input XPS document: A 2-page document generated by my application, which consists entirely of tables and text, save for an image in the header.
Output PDF document: A 2-page document; however, each page is blank -- except for a small, solid black rectangle in the upper left corner of each page, and except that the image in the header appears on both pages in the right spot.

Trial 2
Input XPS document: A 1-page simple document I created for text purposes. The only content is the text "Hello World!" with no font specified (so as to use the default).
Output PDF document: A 1-page blank document.

Trial 3
Input XPS document: A 5-page printout of C# code, printed from Visual Studio 2008 through the Microsoft XPS Document Writer. Due to my personal color settings in Visual Studio, there is a dark green background where any text appears.
Output PDF document: A 5-page document containing no text. However, interestingly, the dark green color behind all of the text *is* present, and the color *is* arranged just as in the input document.

I should also note that I have tried using the text search feature to see if the expected text was in fact present in the PDF file, just not visible, and I was not able to find any of my expected text in either document (only the watermarked Amyuni copyright notice text that is stamped by the developer trial version was present).

Perhaps I am improperly using the library. I would much appreciate any advice from the Amyuni staff or other users.

Thanks and best regards,
Brian
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Re: Converting XPS to PDF not working

Post by Joan »

Hello,

From what I see above , you are using PDF Creator .Net library to convert XPS files to PDF, which version of that library are you using?

Also why don't you use our PDF Converte and print the XPS files to the virutal PDF Printer to get PDF output?

If you wish you can send us a sample XPS file to support@amyuni.com so we can try the conversion using the latest version and check the output.
Custom Brand the Amyuni PDF Printer Driver http://www.amyuni.com/en/developer/branding/index.html

Amyuni PDF Converter tested for true PDF performance. View results - http://www.amyuni.com/benchmark
valvelink
Posts: 2
Joined: Wed Jan 28 2009

Re: Converting XPS to PDF not working

Post by valvelink »

Joan,
Thank you for the response.

Yes, I am using the PDF Creator .NET library. In the properties of the acPDFCreatorLib.Net.dll file, I see the following version-related information:
File version: 3.0.3.4
Product version: 3.03d
Date modified: 10/16/2008
As I mentioned, I downloaded this direct from the Amyuni site just a few days before the original post.

There are a variety of reasons I did not initially wish to use the PDF Converter. Nevertheless, per your suggestion, I decided to try it. I encountered several problems getting it to work. First, I did not immediately realize that I would require the CDIntfNet300.dll (mentioned at the end of the documentation) so I was trying to make use of the COM interface (cdintf.dll), which didn't appear to work from C#. Then, it was not clear where to obtain the license code for the evaluation version, but eventually I found it. Then, all PDF documents I attempted to generate came out to be 0 bytes in size -- but I eventually found an old post from another member on this forum which said I would need to manually reconfigure the printer to use the FILE port instead of LPT1. Finally, I was able to generate PDF documents, but due to the fact that the CDIntfNet300.dll is apparently still under development and is lacking several features I was unable to programmatically set the output file name (therefore I am manually prompted every time) and was unable to specify to embed fonts (which may be why the resulting PDFs appear to have the wrong font).

Due to the complications I encountered with PDF Converter (and the additional complexity of installing and using it), it still seems that PDF Creator would be a cleaner, more desirable solution.

I will forward the XPS file for each of the 3 trials noted in the original post, along with the resulting PDF obtained from both Creator and Convertor, to the email address you listed.

Thanks again.
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Re: Converting XPS to PDF not working

Post by Joan »

Hello,

I will copy here the reply of our support team in case some other users are facing the same issues

Concerning the XPS files, the problem is in the way these specific documents are handled for displaying in the creator control and not with the saving. Our DevTeam is looking into this issue.

Concerning the installation under 64-bits and the port issue, we just uploaded a new version of the PDF Converter that will automatically create the NUL: port and attach the printer to the NUL: port under 64bit systems. The developer no longer requires to manually do this.

For the .Net wrapper of cdintf (), yes it is still under development, but the output filename settings are exposed in the .NET wrapper. Below is a sample code snippet that demonstrates this.



CDIntf.CDIntfControl PDF = new CDIntf.CDIntfControl ();
PDF.DriverInit ( PDFprinter );
PDF.SetDefaultPrinter ();

//Set output directory and output filename
PDF.DefaultDirectory = Application.StartupPath.ToString ();
PDF.DefaultFileName = Application.StartupPath.ToString () + "\\myfile.pdf"

//Set printer settings
PDF.SetSimPostscript ( false );
PDF.VerticalMargin = 0;
PDF.HorizontalMargin = 0;

PDF.SetDefaultConfig (); //need to call this to apply changes

//Set printing options
PDF.FileNameOptions = (int) sNoPrompt + sUseFileName;

//need to call the enable printer each time
PDF.EnablePrinter ( strLicenseTo, strActivationCode );

//print someting
printDocument1.Print();

//Reset everything
PDF.FileNameOptions = 0;
Custom Brand the Amyuni PDF Printer Driver http://www.amyuni.com/en/developer/branding/index.html

Amyuni PDF Converter tested for true PDF performance. View results - http://www.amyuni.com/benchmark
Post Reply