Having read up on this issue for a few hours, I am coming round to the idea that it is not possible to embed a PDF file into the Executable itself - that the only way it happens is by having an "associated" folder that you have to pass along with the executable.
However, before I entirely scrap the idea, I thought I would check here to see if anyone knows of a workaround?
I am not looking for the user to open the PDF in a PDF reader, I am using WebBrowser to display the PDF - which works fine - but when compiling into an Executable using Fody - it produces a Folder called "Resources" and if I move the standalone Executable elsewhere (despite being almost exactly the size of the PDF larger than a compiled executable without the PDF) it says it cannot find the PDF.
I was wondering whether the workaround is have a URI that is in a different location to the Resource folder? - but I don't know how to do that and have not been able to find a way of doing it.
The PDF is a static document - instructions - that is unchanging.
I have read a LOT of responses on here - it is what I have been doing for the past few hours - but none of them really answer this question.
Can you embed a PDF for display in a WPF application and have a standalone executable?
Steps I have taken:
Bring the PDF into the WPF C# .NET Framework 4.7.2 application as a Resource using the Resource.resx system.
Marking it as Embedded Resource/Resource/Content (I tried all 3)
Marking it as Copy Always/Never/If Newer (I tried all 3)
Code Block
XAML
<WebBrowser x:name="pdfWebviewer"/>
Code Behind
pdfWebviewer.Navigate("blank::about")
pdfWebviewer.Navigate("pack://application:,,,/Test.pdf")
This code is from memory so forgive me if there is an error in capitalisation or something.
This code will display the PDF - but only if you have the Resources folder in the same location as the Executable - and if I am going to do that, I might as well just give people the PDF...
If anyone knows a workaround would appreciate it.
Related
I need to progammatically embed Pdf documents in PowerPoint via OpenXml. According to this: Embedding files into Open XML documents using C# it is possible via OLE32.StgCreateStorageEx methods to create the necessary picture as well as the oleobject.
Unfortunately this doesn't work with current versions of PDF. On a 64 bit OS, this seems to work only with Abobe version 9.Higher version fails with error code 0x8000FFFF which translates to Catastrophic failure. This is actual true after testing it. Even the version 9 does not work reliable.
As a fallback, I used pdfium by google to create a png from the first page. This unluckily is only half the way, as the incorporated oleobject is very different from the original one. That does not hurt until the user tries to open the embedded document via doubleclick within Powerpoint. Then an error message comes up, saying the application of the document cannot be found.
Here my questions:
Has anyone information about how to improve the procedure to make it working even with never versions?
Does anybody know what the changes to the pdf document are that are necessary to incorporate a similar object like pdf does it?
Any hint is highly appreciated
Finally I made it running. Have a look here for explanation.
Actually there is only one difference compared to the code in Embedding files into Open XML documents using C# . When calling, StgCreateStorageEx OLE32.STGFMT.STGFMT_DOCFILE has to be used instead of STGFMT_STORAGE.
That makes it running even with newer Adobe versions.
I am developing a ASP .NET MVC application where users are able to upload files to a repository. Those files could be pdf, doc, any type of image and so on.
When the user select a file to be imported I would like to display this file in the browser so they can review its contents before the upload.
I know I could use some sort of IFrame to display pdf but I am looking for some specific class or .net libraries to implement this feature.
I just need a north.
This is an extremely difficult problem. There are some libraries that can help. For instance PDF files might be rendered to images with ghostscript. Word and Excel files might be converted to PDF or image with a number of libraries. None of them, AFAIK, are very good at it so I can not recommend one.
You could automate MSO to perform the conversion to PDF, but that is decidedly not safe for server code. Another possibility is convert source documents to SWF files (like flexpaper) and display in flash. There are some great libraries out there, but it will limit your supported clients. Sharepoint has support for providing some of this capability as well. Others have used OpenOffice to convert MSO documents but also at a loss of quality.
I can't really advise any specific direction as it is highly dependent on what you/your company is willing to spend and the desired results. Good luck.
You could try to rely on Windows and the explorer thumbnails for it, like here, but then you'd have to make sure that:
You can abuse the server in the most elaborate way (install stuff, talk to the shell from ASP.NET)
You have a thumbnail provider installed on the server for every type that you want to preview. I guess from the moment you can see the thumbnail in explorer, you're set. So for pdf, you might need to install PDF Reader from Adobe.
Docx files should be saved with thumbnail checked (see link). There seems to be no other easy, free way to convert a docx to a thumbnail. The "best" solution I came across, was saving it automatically again somehow, and making sure the thumbnail option is checked.
I don't want to say that's impossible, but it can't be done with finite effort.
What you are asking for is a browser-based solution, because you want the user to be able to "review" the document before uploading.
Therefore you cannot use a server side solution, which is essentially what is being asked by referring to a ".Net library".
.Net libraries are dependent on an installed version of .Net, which does not exist in all versions for all operating systems for which graphical browsers exist.
Next, recent changes in browser security do not allow to read the full client-side file name of the selected file in the input field.
You'd have to rely on HTML5 and its FileReader to access the file's byte stream, but even then you can only retrieve image from image files. (see sample)
Excluding browser-based solutions in Flash, ActiveX, Java, due to browser and platform support, this leaves JavaScript as the only "reasonable" solution: you'd need a library for each supported format to either convert a file into an image in an image format supported by browsers, or extract the text(+image) representation of a file.
Great awnsers... Just want to share the result of my research and I found a nice client-based solution supported by Mozilla Labs. This is a framework based on HTML5 and Javascript with no native code needed.
Here the project website:
https://github.com/mozilla/pdf.js
This is what you are capable of:
http://mozilla.github.com/pdf.js/web/viewer.html
And for the last a great video explaning how everthing works
http://www.youtube.com/watch?v=Iv15UY-4Fg8&noredirect=1
Reguarding my question we are going to converter every possible file to PDF on the server and then render this PDF using this framework.
Hi i'm new programming and i have written few application to access pdf content by using some dll files, but now my question is how can we write our own dll to access the pdf files. I know it's a big process but i'm very much interested to learn about this. any one please help me.
You can start by reading the PDF specification (warning 32MB behind this link) in order to understand how the PDF file format is implemented. This is necessary if you want to be able to parse it and extract the information you are interested in.
In the meantime (as this reading might occupy you during a certain amount of time) if you have pressing project deadlines you probably want to use an existing library such as iTextSharp.
I know it's a big process but i'm very much interested to learn about this.
That's true. I'd like to suggest to study some open source APIs (iTextSharp) and PDF SDK.
I'm building a video system, and have came across a problem of accessing a video held in a remote location. Now predicament is that I don't want to mess around with the zip file by extracting the data, this would take too long from a user perspective and would rather be able to open video file directly from within side the zip. My question is, is this possible? The ability to open a file is not something I've found within the DotNetZip library.
The only solution I've found is pointing VideoLAN at the zip file and playing it from there. However, doing this programmatically is something I'm massively struggling with, through the VideoLan DotNet for WinForm & WPF C# plugin and it's lack of examples. Just wondering is there any alternative means?
Why dont you use the VLC ActiveX Directly ,just import the AxVlc.dll to you're project ,than you can select the VLC Plugin from Toolbox in VS (VLC Plugin v2 prefered).
Than you can do something vlc.playlist.add("FileName",Null,""); than use vlc.playlist.play(); version's under 0.9.9 works with Loop ,new version's you should build the Loop Function by you're self.
What's the reason of compressing video files? They are already compressed, and far better than zip can do.
I have a task to print a batch of illustrator files.
There are 8 AI documents and 1 CSV file. In the CSV file there are info that I need to change in the AI document before printing.
Actually I am doing this by using the AI reference in Visual Studio and using doc.printOut(), my problem is that it sends 1 file per printOut() to the printer and it is not that fast, the more printers I have, the more delay to send the document between the printers.
I was wondering if I could use another library to print this or use another function from this library. Maybe even using some batch actions inside illustrator, but I guess that wouldn't change much in performance, Well, I don't know.
Was reading some threads here and saw that the AI file is nearly identical to a PDF file, maybe load the documents within a adobe PDF reference in C# would help to print faster?
Any tips please?
Looking at the VBScript reference for printOut() I'm guessing that Illustrator does a lot of work before firing off a given print job (the PrintOptions object is a collection of options each of which has a dozen or so different settings to twiddle... no thank you).
I suggest you SaveAs() your file to PDF, and print that instead. PDFSaveOptions has a crap-load of options itself, but it looks like (almost?) all of them are optional.