 |
|
 |
Does anyone know if PDFSharp can export images in a PDF file, more specifically the first image (the cover)? I can do it with ghost script but its such a hassle having to install gs and run this long ass command for each PDF file:
gswin32c.exe -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dUseCropBox -dMaxBitmap=500000000 -dFirstPage=1 -dLastPage=1 -dAlignToPixels=0 -dGridFitTT=0 -sDEVICE=jpeg -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r100x100 -sOutputFile=output.jpg "Y:\EBooks\Computer\Programming\Perl\(2002) OReilly - Perl and XML.pdf"
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
As far as I know, PDF Sharp can only create PDF files, and not open existing ones. A thing I needed a while ago was to extract the plain text from a PDF file. For that I needed a library which could use PDF files as input. I found the solution to be PDF Box. It might also help you to take the images. Check it out. However, this too is not hassle free, as you must add dll files which sum up to about 15 MB. (IKVM, because PDF Box is originally a Java library) I remember seeing an article on this here on CP, too. Hope this helps. Good luck!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Wow, you're right 15MB certainly is a liability for a single call to a PDF file (GetBookCover routine). Thanks for the tip though, I will bookmark it for future use if I need to d more with PDF files.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi,
I want to save the image(small as well as large image) in center of the pdf page. How can I do that?
Please suggest some idea.
Thank You
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
You can set the size of the PDF page using the properties "doc.Pages[0].Width" and "doc.Pages[0].Height". Do the calculations on where you want the image to be put, and instead of drawing it at coordinates (0,0), draw it at the coordinates that you came up with.
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
An Exception occured when converting BMP to PDF as following:
NotImplementedException: Image format not supported. at PdfSharp.Pdf.Advanced.PdfImage.InitializeNonJpeg() at PdfSharp.Pdf.Advanced.PdfImage..ctor(PdfDocument document, XImage image) at PdfSharp.Pdf.Advanced.PdfImageTable.GetImage(XImage image) at PdfSharp.Pdf.PdfPage.GetImageName(XImage image) at PdfSharp.Drawing.Pdf.XGraphicsPdfRenderer.GetImageName(XImage image) at PdfSharp.Drawing.Pdf.XGraphicsPdfRenderer.Realize(XImage image) at PdfSharp.Drawing.Pdf.XGraphicsPdfRenderer.DrawImage(XImage image, Double x, Double y, Double width, Double height) at PdfSharp.Drawing.XGraphics.DrawImage(XImage image, Double x, Double y) at PdfSharp.Drawing.XGraphics.DrawImage(XImage image, Int32 x, Int32 y)
What's the problem?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hmmm... this never happened on my BMP files. Maybe your image is in another fancy format with incorrect BMP extension... If you have a sample image to demonstrate this, you can send it to me by email. Just add '@gmail.com' after my user name. Or it might just be a bug in PDFSharp, in which case we'll have to look on their forum for help. Regards.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi blackjack2150,
I had sent the email attached the BMP to your mailbox,blackjack2150@gmail.com. Please have a check and verify what's the reason is?
Your help will benifit me a lot.
Thank you very much.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
|
 |
|
|
 |
|
 |
hiiiiii, how to convert a pdf file to image file in c#.net? Its an immediate requirement,plz help me out !!!!!
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
As far as I know, PDFSharp is only for creating PDF files, not for reading information or converting existing PDF files.
For your need, I think you should look for a Virtual printer that can output image files. One that I know of is Bullzip PDF Printer. Most of the time it is used to produce PDF files, but there is also the option to choose and image format instead of PDF.
Insert funny quote here.
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Hi all.
I have an little apps in vb.net to trasform tiff-ccit4 on pdf.
Using itextsharp it's very slow (30kb tiff --> 30sec on pdf conversion) Using pdflib work fast but i have incompatibility with another apps that use itextsharp.
It's possible to use your project on vb.net? If yes, how?
Im newbee and sorry for my english
Best regards
modified on Tuesday, December 16, 2008 1:41 PM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Of course it is. Just add a reference to PdfSharp.dll and use the code in the article in the VB.NET equivalent.
Insert funny quote here.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
As i faced this problem i solved it within a vary short time.
To do the conversion for the multiple Tiff files
do the folowing code give below.
private void bw_DoWork(object sender, DoWorkEventArgs e) { try { string source = (e.Argument as string[])[0]; string destinaton = (e.Argument as string[])[1]; PdfDocument doc = new PdfDocument(); doc.Pages.Add(new PdfPage()); XGraphics xgr = XGraphics.FromPdfPage(doc.Pages[0]); XImage img = XImage.FromFile(source);
xgr.DrawImage(img, 0, 0);
doc.Save(destinaton);
doc.Pages.Add(new PdfPage()); XGraphics xgr1 = XGraphics.FromPdfPage(doc.Pages[1]); xgr1.DrawImage(img, 0, 0); //xgr.Clear(new XColor());
doc.Save(destinaton); doc.Close(); success = true; }
Ashish Joshi IT Expert
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Dim img As Image = Nothing 'armazena informações da imagem Dim frameDimension As System.Drawing.Imaging.FrameDimension = Nothing 'armazena informação da dimensao do frame Dim frameCount As Integer = 0 'armazena quantidades de frame(paginas) Dim xgr As PdfSharp.Drawing.XGraphics = Nothing Dim pdfimg As PdfSharp.Drawing.XImage = Nothing
img = Image.FromFile("c:\Arquivo.tif") 'file to convert frameDimension = New System.Drawing.Imaging.FrameDimension(img.FrameDimensionsList(0)) frameCount = img.GetFrameCount(frameDimension)
Dim doc As New PdfSharp.Pdf.PdfDocument() For index As Integer = 0 To frameCount - 1 'Seleciona o frame atual img.SelectActiveFrame(frameDimension, index)
doc.Pages.Add(New PdfSharp.Pdf.PdfPage()) xgr = PdfSharp.Drawing.XGraphics.FromPdfPage(doc.Pages(index)) pdfimg = img
xgr.DrawImage(pdfimg, 0, 0) Next
doc.Save("c:\Arquivo.pdf") 'file full path doc.Close()
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
i have gone throgh the code of PDFDocument Class, so kindly tell me the solution for the multiple files as well. thank u.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
That should be trivial, provided you know how to use any loop instruction. (for, foreach, while, do while)
Keyboard not found. Press F1 to continue.
|
| Sign In·View Thread·PermaLink | 1.00/5 (2 votes) |
|
|
|
 |
|
|
 |
|
 |
After you do, if you have time, I would appreciate if you posted a few impressions about PDFSharp, compared to iTextSharp. All the best!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
 |
In the first version, if you try to convert a wide image, it might get trimmed because the right side will be out of the PDF page margin. Here is a fix:
Replace the line
xgr.DrawImage(img, 0, 0); with
if (doc.Pages[0].Width < XUnit.FromPoint(img.Size.Width)) doc.Pages[0].Width = XUnit.FromPoint(img.Size.Width);
if (doc.Pages[0].Height < XUnit.FromPoint(img.Size.Height)) doc.Pages[0].Height = XUnit.FromPoint(img.Size.Height); xgr.DrawImage(img, 0, 0, img.Size.Width, img.Size.Height);
This will extend the width and/or the height of the page, depending on the case. If you want to make the PDF page to have the exact size of the image that was inserted, replace that line with this code:
doc.Pages[0].Width = XUnit.FromPoint(img.Size.Width);
doc.Pages[0].Height = XUnit.FromPoint(img.Size.Height); xgr.DrawImage(img, 0, 0, img.Size.Width, img.Size.Height);
I will probably update the article and the code to include this fix, but until then I just wanted to point this.
All The Best!
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |