|
|
Originally Posted by: Paul Rayman  That was amazingly easy to follow and to adapt to my needs. It is also running about 700% faster than PDFSharp and more reliably than the Adobe SDK... I am going to see what the boss will do about a license for me! Thank you so much!!! If my classes were as easy to understand as the blog post you wrote, this would be done ages ago. You pretty much just saved my job by the way! Thanks!
|
|
|
Thanks, I'll run it through as soon as i get the chance.
|
|
|
|
|
|
Originally Posted by: Paul Rayman  Are you tried to make changes with the matrix, as suggested above? Yes, I have adjusted the matrix, utilizing the code provided above, taken from the example provided. (line 37) The result yielded is that right side of the image is simply not present after lockBits(), or maybe after the matrix transform. I am not sure, since I am in fact using the resulting image as my output. (line 19) The data doesn't seem to be making it through the steps. This is evidenced by the fact that the image data, when shrunk or enlarged continues to see the exact same loss. I iterated through 243 images to check as well, there was no change. In the example I sent to the above poster, I showed the original image, and the created pdf(with the rigthmost ~10% missing). The code above is directly based off of the example provided by patagames on the pdfium forum.It contains the routine which, when called uses the matrix transform to size the image. This is not my code, it's actually yours. Thanks for any help you can provide.
|
|
|
Are you tried to make changes with the matrix, as suggested above?
|
|
|
I sent that code, the Tif and the pdf it made
|
|
|
Could you please provide a full code and your tiff image. You can send it to pr@patagames.comIt seems the original image and a page that you are created has different size. Try to pass into SetMatrix method the page's size instead of image's size. image.SetMatrix( page.Width, 0, 0, page.Height, (float)atPoint.X, (float)atPoint.Y);
|
|
|
A quick update, having looked through the other examples I've added this code Which is generating a page now. However, while the pdf page is 36inches wide and 24 tall, as it should be, it is only rendering the bottom left corner of the blueprints. Roughly 1/16 of the size. How do I fix that part?
|
|
|
Hello, What I have. The application currently works using the Migradoc libraries, but they produce a fair number of PDF that cannot be read by adobe. It loads a tiff and gets the dpi etc from construction blueprints. It then makes a single page pdf and saves it. DPI is a must here, as the resulting file are used in estimating software, as is page width of the pdf and so on. Here is the desired behavior. Load an image based on processing options, and then this Code:
using(Bitmap InsetImage = Blueprint as Bitmap)
{
using(PdfDocument docu = PdfDocument.CreateNew())
{
docu.Pages.InsertPageAt(0,pagewidth,pageheight);
var image = InsertImageToPage(docu,docu.Pages[0],InsetImage,new PointF(0,0));
docu.Save(tmpPath,Patagames.Pdf.Enums.SaveFlags.NoIncremental);
}
}
static public PdfImageObject InsertImageToPage(PdfDocument doc, PdfPage page, System.Drawing.Bitmap bmp, PointF atPoint)
{
var bi = bmp.LockBits(
new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height),
System.Drawing.Imaging.ImageLockMode.ReadOnly,
System.Drawing.Imaging.PixelFormat.Format32bppArgb);
//Create PdfBitmap object from .Net bitmap
var bitmap = new PdfBitmap(
bmp.Width,
bmp.Height,
Patagames.Pdf.Enums.BitmapFormats.FXDIB_Rgba,
bi.Scan0,
bi.Stride);
//Create pdf image object and then set PdfBitmap object into it.
var image = PdfImageObject.Create(doc);
image.SetBitmap(bitmap);
//Scale image object to it's actual width and heihgt
image.SetMatrix(bmp.Width, 0, 0, bmp.Height, (float)atPoint.X, (float)atPoint.Y);
page.PageObjects.InsertObject(image);
bmp.UnlockBits(bi);
return image;
}
That mess produces a bank white page with the proper dimensions. I previously tried the code found here. https://forum.patagames....ge-into-newly-added-pageI have also read the API docs and am having no luck at all. I don't/can't start with a pre-existing pdf, which every single example shows. I've been at this for about a week with no luck at all. Is there a simple example of: Create PDF Add Page[0] Stuff an indexed Tiff in there Set height width and dpi Save that bad boy. Or at least an explanation that can help me understand why the data from InsertImageINto Page isn't doing it's thing. Should I be using the return? Am I passing the page wrong?
|