I am using Pdfsharp 1.32.3057 to draw graphics (some paths). It might happen, that these graphics are larger than the final print format (A4 page format).
Therefore I want to split graphics larger than the final print format to multiple pages. I also want to include some marker on where one could cut off margins of the printed pages using scissors and then align them next to each other so they apppear like one large page and the graphic becomes complete.
Any idea on how I could realize this splitting?
Thanks for any hint on this!
What I would do: draw the graphics on an XForm with the size you need for the graphics.
Then draw chunks of that XForm on the page with the size and offset you need (offset will be negative for second+ row and second+ column.
Then draw four white rectangles over of the image borders if you want to have borders. Draw your markers/scissors over the rectangles.
This way you will draw the same XForm on all pages. PDFsharp will include a single instance of the XForm in the PDF file. You can also add a page that shows the complete image - this will add few bytes only to the PDF file and will be more comfortable for those watching on the screen and for those who can do with a shrunk single-page printout.
Related
I have a PDF that is a template I will use to print onto special paper stock in a printer. I want to create a way to use the mouse to capture x,y locations when i click on certain areas of the pdf. The pdf template is based on an 8 1/2 x 11 piece of paper.
One of my ideas was to convert the page in the pdf to a jpg and load it into a picturebox using c# and a windows forms application. Then I can capture the x,y when i click the mouse but I'm not sure how that will translate to the pdf.
I'm open to opensource suggestions but I also have both the Aspose Words and Aspose PDF products. I'd also prefer a .NET solution.
Rather than storing a direct X/Y pixel co-ordinate then, you could store them as a % of the page.
So go down your jpeg idea, get the pixel X,Y of your location, then divide those by the Width,Height of the Jpeg to give you X%,Y%
When you come to do your printing, get the paper size and multiply that by your X%,Y% to get your offset within the print document
In the end what worked for me was finding out that 1 inch = 72 points. So as far as the Aspose library was concerned that conversion factor worked for me. THEN I created a jpeg that was 1 pixel by 1 pixel and would stamp that on the PDF using the XIndent and the YIndent. This allowed me to stamp a pixel in the upper left corner of pdf and then using the width and height of the page and the conversion factor I was able to deduce the other 3 corners!
I am drawing lines on a background image in a c# panel. The panel is anchored to the form so as the form resizes the panel resizes. The background image is set to be stretched so all you see as you resize the form is the background image.
My initial problem:
The lines drawn on the panel (via the OnPaint event) stay where they were originally drawn as the image resizes.
My current solution:
Record the location of the line and redraw it on a new bitmap by scaling the X and Y coordinates (works fine).
My new problem:
As you continually resize the window and draw lines you can't calculate the scaling factor from any point in time and apply it to all lines since the lines were originall drawn in different size images.
The two options I think I have:
After I redraw the line go through my array of lines and update the coordinate information so it now matches the current scale.
Or
In addition to storing the coordinate information of the line also store the size information of the panel at the time it was drawn so I can always calculate the scale for each line based on when it was drawn and the new panel size.
What I'm hoping for:
If you have thoughts on either of the two approaches that would be greatly appreciated....Even better would be to point me in the direction of a far better method to do this (I am fairly new to graphics processing in c#).
Can't write a comment, much as I want to. You do have a few options:
Draw your lines directly on the original Bitmap. This might not be an option for you, depending on the task.
Do it as you're doing now, keeping track of the lines' coordinates, updating them on resize, and redrawing them on Paint - if you use this, you'll be able to move and delete them, too,
Or do it by introducing a "scale factor" (float) which you update on every resize, and in your Paint event handler you draw everything using that scale factor. As you create a line, you calculate its coordinates using the scale factor BACK TO an unified coordinate system (scale factor 1) and then you don't have to modify your coordinates at all. This might be easy to debug due to that unified coordinate system. This is what I'd recommend, but it again depends on your task.
Draw to a full transparent Bitmap of the same size as your original image, use a scale factor like in the previous option. On creating a line, calculate its coordinates in the unified coordinate system, draw it on the Bitmap, and then on every Paint, draw the entire Bitmap over your original one. This, again, might not be an option if you need to delete or move your lines, or if you're tight on memory, or you don't want your lines to be blurred when you scale up, but somehow many ppl like this because it's like a "layer in Photoshop". :)
I have an image frame:
1 http://i48.tinypic.com/wugmc2.png
The image resolution is: 533x300
Using GDI+ I Re-size the image to 300x533:
Now as you can see it distorted the width/height of the border and shrunken Santa Claus...
Is there a way using GDI+ c# to prevent this distortion of the image frame?
Scaling the image will always result into a skewed santa. If that is not what you are looking for, try creating separate images of your santa and the border.
If the border will stay that simple as a red line, I am almost sure that there is a simple control for just drawing red borders in GDI. If you are going to create some christmas border with branches and trees, you need a bit more smaller images to separate this problem.
Create a separate santa to use as an overlay
Create separate images for the corners
Create separate tillable images for vertical and horizontal borders
Then place the images by yourself and tile the images in the centers like so:
I have never worked with GDI, but this is a general solution for scaling borders.
I have an image embedded in a PDF file. I was able to extract the resolution of the image. However, if i crop the PDF using iTextsharp and a part of the image is cropped in the process. The new image continues to have the same resolution. By resolution I mean the dimension in the form of Width x Height. The cropped image is supposed to have a smaller size. How can I extract the size of the image in inches, if possible, so that I can differentiate the original image from the cropped pdf?
Embedded images in PDFs are never "cropped" in the sense that the "cropped-away" parts are gone forever. They are only cropped in the sense that these parts are hidden or masked.
If the image data inside the PDF say /Height 216 and /Width 288 then this is the size in Pixels (not inches or any other length unit). And "resolution" is then secondary:
if the PDF environment commands that this image should be rendered onto a square of 3x4 inches, its resolution in this moment is 72x72 dpi.
if the PDF environment commands that this image should be rendered onto a square of 1.5x2 inches, its resolution in this moment is 144x144 dpi.
However it can well be that the image is only partially visible ("cropped"), maybe because half of it is rendering beyond the page borders...
I have documents that are being scanned that are less than 8.5 x 11. They are probably more like 8.5 x 5. The scanners being used are centering the documents vertically and still making 8.5 x 11 TIFFs. I'm looking for a way to automatically remove the white space from the top and bottom of the images. If the image's orientation is changed, there could potentially be excess white space on all 4 sides of the image. Assume there is no setting on the scanner to prevent it from doing this.
tl;dr
Does anyone know of a decent TIFF library that can auto crop images?
You don't necessarily need a "tiff library" to do this. you could do it in c#, something like this...
convert the tiff to a bitmap
inspect the bitmap, pixel by pixel to determine where the whitespace starts/ends
once you know the pixel coordinates of the surrounding whitespace, you can then crop the bitmap image
save the new image
Reference these pages for more information:
http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.getpixel%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.croppedbitmap%28v=vs.85%29.aspx