Free way to convert PDF to XPS with C# - c#

Are there any free tools that I can use to convert a PDF document into an XPS document? Although a nice programmatic API would be nice, I'm not opposed to shelling out to a command line tool to do the conversion.
Thanks!

AbcPdf version 7 includes this funcationality, if you link back to their site you can have a free license key. Utilize the save method to accomplish PDF - XPS conversions.
XPS is exported only if the supplied path ends with ".xps", and it requires the .NET Framework 3.0. XPS is supported via Doc.SaveOptions.FileExtension of the Save method when saving to a stream. Set this property to either ".xps" or "xps" otherwise a conventional PDF output will be generated. XPS streams must have FileAccess.ReadWrite and not simply FileAccess.Write otherwise the operation will fail.
virtual void Save(Stream stream)

Related

Unable to convert PCL file to PDF using Filestream and PDFSharp

I was unable to find a free library which can directly convert PCL file to PDF file, i had a thought of reading the PCL file into FileStream and saving it to a PDF document using PDF Sharp.
I tried the following code, but it gives me a blank PDF Document.
Can someone let me know what or where i'm doing it incorrectly?
private void pdfSharpPclToPDF(string localPCLPath)
{
using(FileStream fleStream = new FileStream(localPCLPath, FileMode.Open))
{
using (PdfDocument newPDF = new PdfDocument(fleStream))
{
PdfPage pdfPage = new PdfPage(newPDF);
newPDF.Pages.Add(pdfPage);
newPDF.Save("D:\\Research\\PDF_Files\\output.pdf");
}
}
}
It would also help if someone could suggest any other open source library that can do the job for me.
PDFsharp does not use the filestream you create. If you invoke Save() without filename, PDFsharp will save the PDF document to the stream. If you invoke Save(<filename>) the document will be saved in that file.
PDFsharp cannot read PCL files. You are trying something that cannot work with PDFsharp.
Most Applications will usually include some way to export content as a printer output. The higher end various output formats are generically referred to as PDL (Page Description Language) and historically were stored as filename.prn without distinguishing content.
The contents of a PRN could traditionally be Esc code as used by Epson , PostScript Programs or PCL (Printer Control Language) plus many others and nowadays we often include the formerly dumber PDF which is accepted by high end printers.
So PDFsharp can Export to PCL via a driver but is not designed to Import it for conversion into PDF output.
One application that can convert bidirectionally between PDL devices is Artifex GhostPDL (it does NOT Import Epson Esc Code but can export Epson code). GhostScript is Open Source, as you request, but is (AGPL) commercial licensed. However it is the most capable with a few decades of history.

SILENT conversion of PDF to XPS with "Microsoft XPS Document Writer"

I need to convert a bunch PDFs to XPS documents programmatically (in C#). Therefore, I tried to call several command line tools:
AcroRd32.exe (Adobe Reader)
SumatraPDF.exe (neat portable tool)
PDF2Printer for Windows 10
and many, many others.
However, none of them seems to support functionallity to specify a filename for the generated XPS, which causes the "Save-Dialog" to pop-up on call. I am looking for a complete silent way to convert a PDF to XPS without any user interaction. Furthermore, I wish to use only tools that are free for commercial use (without any AGPL licensing). Any workarounds for this issue?
The following lib supports to convert pdf to xps and specify file name for generated xps file but with limitations: http://freepdf.codeplex.com
PdfDocument doc = new PdfDocument();
doc.LoadFromFile("FileName.pdf");
doc.SaveToFile("FileName.xps", FileFormat.XPS);

Using OpenXML to save a PowerPoint presentation as a PDF

My objective is to make an automated server-side process to turn a .ppt into a .pdf. Microsoft themselves suggested that I use OpenXML, and now I'm looking at that.
My question is:
Can I actually achieve my objective using OpenXML?
I'm having a hard time finding the methods that I'd expect, such as "save as" here
Or perhaps I'm just misunderstanding how it all works?
... to turn a .ppt into a .pdf. Microsoft themselves suggested that I use OpenXML ... Can I actually achieve my objective using OpenXML?
For the conversion of a .ppt into .pdf? I'm curious to see where you have read this ;-)
No It's just impossible using OpenXml SDK:
OpenXml SDK permits to create, modify OpenXml documents (.pptx in case of PowerPoint) and here you are talking about .ppt (Biff format)
There is NO method for converting as PDF. OpenXml SDK permits to retrieve, create, modify the content of the document Without an Office Application but DOES NOT contain any methods to render it, or such Office Application methods such as SaveAs() ...
No, a common way to convert Office documents as pdf is to use Office.Interop.
This thread How do I convert Word files to PDF programmatically? is related to Word but it can help you, it's the same with PowerPoint.

How can I convert PDF to doc without microsoft.office.interop?

I need to convert PDF files into .doc files using C#. The computer has no file system though it doesn't have Office installed. Any good ideas how I can approach this? I did some research and most of people use the interop services.
You need to understand that PDF is not really implemented as a single document format.
If your PDF docs are created by rendering text to a PDF file, then direct PDF conversion is not only possible, but can be very good (reliable).
If the source of your PDF is either a scanner or fax (essentially a scanner...) then what you have is a document with an "picture" of text. This scenario is more difficult to deal with. If you open up the markup for this there is no 'text' to be converted. In this situation you have to deal with some manner of OCR (optical character recognition) which is less reliable due to a variety of issues.
If you have the option of intercepting the data before it is rendered to PDF (say like in SSRS or Crystal) then it would be better for you to bypass the PDF stage and move your data to a Word document.
If you are constrained to receiving faxes and then needing to interpret their content, prepare for OCR hell. It has been a while since I was there, so I hope that it has gotten better.
Even with out office installed on your machine, you have access (with Visual Studios) to the Office developer toolkit which will allow you build documents to be distributed in the Word formats.(.doc/.docx).
An option/idea may be to convert the PDF to Html, which can be opened in Word?
use aspose pdf kit to conver pdf to text and then text to doc using filestream or aspose doc

HTML to Image .tiff File

Is there a way to convert a HTML string into a Image .tiff file?
I am using C# .NET 3.5. The requirement is to give the user an option to fact a confirmation. The confirmation is created with XML and a XSLT. Typically it is e-mailed.
Is there a way I can take the HTML string generated by the transformation HTML string and convert that to a .tiff or any image that can be faxed?
3rd party software is allowed, however the cheaper the better.
We are using a 3rd party fax library, that will only accept .tiff images, but if I can get the HTML to be any image I can covert it into a .tiff.
Here are some free-as-in-beer possibilities:
You can use the PDFCreator printer driver that comes with ghostscript and print
directly to a TIFF file or many other formats.
If you have MSOffice installed, the Microsoft Office Document Image Writer will produce
a file you can convert to other formats.
But in general, your best bet is to print to a driver that will produce and
image file of some kind or a windows meta-file format (.wmf) file.
Is there some reason why you can't just print-to-fax? Does the third-party software not support a printer driver? That's unusual these days.
A starting point might be the software of WebSuperGoo, which provide rich image editing products, cheap or for free.
I know for sure their PDF Writer can do basic HTML (http://www.websupergoo.com/helppdf6net/source/3-concepts/b-htmlstyles.htm). This should not be too hard to convert to TIFF.
This does not include the full HTML subset or CSS. That might require using Microsofts IE ActiveX component.

Categories