 |
|
 |
I ran into a problem with only a few tiff to pdf files. I am not sure why only the specific ones were doing this however after I converted from tiff file to the pdf; the image within the pdf document was always squished to only half the page. In my case I changed the multiple page to pdf to something like this.
for (int i = 0; i < frameCount; ++i) { imgTiff.SelectActiveFrame(frameDimension, i); PdfPage page = docRet.AddPage(); page.Size = PageSize.Letter; page.Orientation = PageOrientation.Portrait; xgr = XGraphics.FromPdfPage(page); pdfimg = XImage.FromGdiPlusImage(imgTiff); xgr.DrawImage(pdfimg, 0, 0, page.Width, page.Height); }
Take not the page width and height. This forced the tiff image to take the whole page.
|
|
|
|
 |
|
 |
I noticed most of the questions about this subject matter are about methodology and logic rather than functionality. Check out the official website for PDFsharp, there are multiple examples and help for the source code and library which are downloadable.
Dagdason
http://www.pdfsharp.net/wiki/MainPage.ashx
|
|
|
|
 |
|
 |
Good advice. Maybe I should also update the article, because since it was published the PDFSharp website and forum have moved.
|
|
|
|
 |
|
 |
Hello,
I used the appliation and it is running excellent but I my project need to convert more than one image file to one PDF file can anyone help me in that.
Thanks,
|
|
|
|
 |
|
 |
Here is my code for a TIFF file with multiple images
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(); Image myimage = Image.FromFile(source);
System.Drawing.Imaging.FrameDimension oFDimension = new System.Drawing.Imaging.FrameDimension(myimage.FrameDimensionsList[0]); int iCount = myimage.GetFrameCount(oFDimension) - 1;
for (int index = 0; index <= (iCount); index++) { PdfPage page = doc.AddPage(); page.Size = PageSize.Letter; page.Orientation = PageOrientation.Portrait; XGraphics xgr = XGraphics.FromPdfPage(page); myimage.SelectActiveFrame(oFDimension, index); XImage img = XImage.FromGdiPlusImage(myimage); xgr.DrawImage(img, 0, 0); }
// XImage img = XImage.FromFile(source);
// xgr.DrawImage(img, 0, 0); doc.Save(destinaton); doc.Close(); success = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
|
|
|
|
 |
|
 |
hi..all,
We are going to make PDF file from image tiff. Also we have co-ordinate information of the text. Now we want to hide the text in specified position. Is this dll has facility to hide the text in specified position?
Is there is any dll available for that..i am using itextsharp buts its not working.
Please Help me..
any example would be appreciated..
Thanks, Raj
|
|
|
|
 |
|
 |
Hello ,
I am using to merge multiple PDF to Single Pdf.
for that purpose i am using pdfsharp..its working fine but when i see the properties of that merge pdf his fast web view is False.
while all PDF fast web view properties is TRUE. after merging its become False.
so how i fix this problem...anyone help me...
here is my code...
private void CreatePDF() { // Get some file names if (GetFiles().Length == 0) { MessageBox.Show("NO PDF Files Found in the Directory"); } else { FileInfo[] files = GetFiles();
// Open the output document PdfDocument outputDocument = new PdfDocument();
// Iterate files foreach (FileInfo file in files) { // Open the document to import pages from it.
try { PdfDocument inputDocument = PdfReader.Open(file.FullName, PdfDocumentOpenMode.Import); // Iterate pages int count = inputDocument.PageCount; for (int idx = 0; idx < count; idx++) { // Get the page from the external document... PdfPage page = inputDocument.Pages[idx]; // ...and add it to the output document. outputDocument.AddPage(page); outputDocument.ViewerPreferences.Clone(); }
logger.log("Completed Processing " + file.Name); } catch (Exception ex) { //MessageBox.Show(ex.Message); logger.log(ex.Message + " error occured while processing " + file.Name); } }
// Save the document... string filename = txtOut.Text; outputDocument.Save(filename); MessageBox.Show("Files are merged successfully"); // ...and start a viewer. Process.Start(filename); } }
so Please help me...!
Thanks, Raj
|
|
|
|
 |
|
 |
Have you tried asking this on the PDFSharp forum? My experience with this library is limited to the topic of this article, but on the official forum[^] you would have better chances to get help.
|
|
|
|
 |
|
 |
Hi,
This is a great program. But only converts 1 page of a multipage TIFF file. Apparently it will do on multipage tiff file also.
Give me some ideas on that.
Thank You
|
|
|
|
 |
|
 |
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(); Image myimage = Image.FromFile(source);
System.Drawing.Imaging.FrameDimension oFDimension = new System.Drawing.Imaging.FrameDimension(myimage.FrameDimensionsList[0]); int iCount = myimage.GetFrameCount(oFDimension) - 1;
for (int index = 0; index <= (iCount); index++) { PdfPage page = doc.AddPage(); page.Size = PageSize.Letter; page.Orientation = PageOrientation.Portrait; XGraphics xgr = XGraphics.FromPdfPage(page); myimage.SelectActiveFrame(oFDimension, index); XImage img = XImage.FromGdiPlusImage(myimage); xgr.DrawImage(img, 0, 0); }
// XImage img = XImage.FromFile(source);
// xgr.DrawImage(img, 0, 0); doc.Save(destinaton); doc.Close(); success = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
|
|
|
|
 |
|
 |
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"
|
|
|
|
 |
|
 |
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!
|
|
|
|
 |
|
 |
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.
|
|
|
|
 |
|
 |
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
|
|
|
|
 |
|
 |
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.
|
|
|
|
 |
|
 |
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?
|
|
|
|
 |
|
 |
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.
|
|
|
|
 |
|
 |
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.
|
|
|
|
 |
|
|
 |
|
|
 |
|
 |
Could you elaborate on that?
|
|
|
|
 |
|
 |
Is there any way that we can convert multiple tif files in to a multiple page pdf?
|
|
|
|
 |
|
 |
hiiiiii, how to convert a pdf file to image file in c#.net? Its an immediate requirement,plz help me out !!!!!
|
|
|
|
 |
|
 |
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.
|
|
|
|
 |
|
 |
yes you can do this with combination of PDFSharp and ghost script. PDFSharp guys write a wrapper class around gs (PDFSharp.GhostScript.dll).
Install Ghost Script and the using pdfshapr.ghostscript.dll method gs.PDFtoPng(document, pageno) it will return a System.Drawing.Image type of image.
System.Drawing.Image nImage = gs.PdfToPng(document, index, 120);
Hope this helps
|
|
|
|
 |