 |
|
 |
I really appreciate for this work. This code helped me a lot. Thanx very much
|
|
|
|
 |
|
 |
Very simply explained and works. I am new top C# and these articles help.
Good job
|
|
|
|
 |
|
 |
Hi,
Your tool is great but I need to process some very large multi-page TIFFs into PDFs. I saw the code sample you had posted that replaced single-page processing with multi-page processing, and it works like a charm for small files. However, if I try to process a large one, I get an out of memory exception, probably because it tries to load every page from the source before converting. Do you know if it's possible to modify your code further to load one page at a time, convert it, save it and then clean up as much memory as possible before loading the next page?
Thanks much!
IZ
|
|
|
|
 |
|
 |
Hi,
How to use this library?
|
|
|
|
 |
|
 |
Nice article, small but effective.
|
|
|
|
 |
|
 |
Hi,
I have a graphic object which get filled up with images by other custom DLL.
Now, I got this graphic object, how do I pass this graphic object to Xgraphics so xGraphic can draw it to PDF?
It looks like XGraphics.Graphic is a read only property.
THanks
|
|
|
|
 |
|
 |
Sadly, I haven't done any PDF work since publishing this article, but may I suggest having a look at these samples[^], on the (new) PdfSharp page? All the best!
|
|
|
|
 |
|
 |
Hi,
I tried to convert an image(having 3000*3000 dimension) to PDF file using your code. The output pdf file contains only a part of the image, not complete image. Could you pls let me know how it works for higher dimensions also. Thanks in advance
|
|
|
|
 |
|
|
 |
|
 |
Thanks alot.. It solves the problem.
|
|
|
|
 |
|
 |
The image is completely occupying pdf document. Can you let me know how to set margins(left,right,top, bottom) and also setting "Paper Size" value as A4. Thanks in advance.
|
|
|
|
 |
|
 |
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.A0;
page.Orientation = PageOrientation.Landscape;
XGraphics xgr = XGraphics.FromPdfPage(page);
myImage.SelectActiveFrame(ofDimension, index);
XImage img = XImage.FromGdiPlusImage(myImage);
xgr.DrawImage(img,0,0);
if (img.Size.Height > doc.Pages[0].Height)
{
doc.Pages[0].Width = img.Size.Height;
}
}
//doc.Pages.Add(new PdfPage());
//XGraphics xgr = XGraphics.FromPdfPage(doc.Pages[0]);
//XImage img = XImage.FromFile(source);
//xgr.DrawImage(img, 5.0, 5.0);
doc.Save(destinaton);
doc.Close();
success = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
me 4000 4000 some of my pics can be some people here in 1024 when 768 of which method do I use Auto-fit picture of the pdf documentation SHOULD ...
help me please...
|
|
|
|
 |
|
 |
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);
}
}
|
|
|
|
 |
|
 |
it worked just fine, but it trimmed the last two lines at the very end footer of the image.
but the drawing function has 12+ overloads and it could be solved as follows by adding the desigred width and height:
xgr.DrawImage(img, leftOffset, topOffset, 550, 790);
Regards,
Maher Abu Zer
modified on Wednesday, June 8, 2011 3:21 AM
|
|
|
|
 |
|
 |
Here is my code for getting all the images in a folder and putting them into one PDF, in the center of the page:
PdfDocument doc = new PdfDocument();
int fileCount = 0;
foreach (string file in Directory.EnumerateFiles(sourceFolder))
{
doc.Pages.Add(new PdfPage());
XGraphics xgr = XGraphics.FromPdfPage(doc.Pages[fileCount++]);
XImage img = XImage.FromFile(file);
double leftOffset = (xgr.PageSize.Width/2.0) - (img.PointWidth/2.0);
double topOffset = (xgr.PageSize.Height / 2.0) - (img.PointHeight / 2.0);
xgr.DrawImage(img, leftOffset, topOffset);
}
doc.Save(destFolder + Path.DirectorySeparatorChar + name + ".pdf");
doc.Close();
-Matt
|
|
|
|
 |
|
 |
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"
|
|
|
|
 |