I am trying to convert pptx to html using c# by exporting every picture as an image but although I've tried all different PpExportMode's, I could not export the shapes with the same size. For instance, an image that's height and width are both 0,37 cm in powerpoint (it's equal to 13.984251969), becomes 20*20 pixel when I exported it. Does anyone know how can I save these shapes with the same size ? I've tried these;
shape.Export(exportPath + "\\" + fileName, PpShapeFormat.ppShapeFormatPNG,(int)slide.Master.Width,(int)slide.Master.Height, PpExportMode.ppScaleToFit);
shape.Export(exportPath + "\\" + fileName, PpShapeFormat.ppShapeFormatPNG,0,0, PpExportMode.ppScaleToFit);
with different PpExportMode's.
Thanks in advance.
Related
I am attempting to add a .PNG image to a PictureBox, but it does not seem to be reading it.
public static String NoteImage_path = Environment.CurrentDirectory + #"\Notes-Images\";
ImageLocation = NoteImage_path + "test" + ".png";
With this exact code, I had no issues adding a .BMP file, so why is there an issue with the .PNG file?
Any help will be appreciated. Thanks!
Add PictureBox on the form
List item
Browse Image property
Resource Context
Import button
Chose Png file.
You can do it by code.
pictureBox1.Load(#"C:\Mine\download.png");
I'm hitting brick walls trying to see if this is possible.
My current scenario is that we have a process (out of our control) that generates PDFs with an image logo in the top left. The image resolution is very low and looks bad. I'm trying to replace it with a vector based version of the logo and I can't seem to figure out how to do this using iTextSharp. I know that I could insert a higher resolution image, but I want a graphic/vector drawing to be there instead (scales with zoom, for the challenge, etc.)
I've tried to figure out if I can copy the PDF draw operands + content for the graphic into a new PDF but this doesn't seem easily doable.
Is there a way to just insert an SVG at a specific position and size using iTextSharp? Or some other way I can insert this vector graphic?
I need to get relationship id of a Drawing object to extract images from Word using OpenXml. I saw Replace image in word doc using OpenXML and I'm using this code now:
string imageId = "default value";
Blip blipElement = selectedImage.Descendants<Blip>().First();
if (blipElement != null) {
imageId = blipElement.Embed.Value;
}
document.MainDocumentPart.GetPartById(imageId);
Works perfectly for usual images, but doesn't work for powerpoint slides which are stored as EMF images inside docx, because EMF Drawing's don't have Blip. But they have ImageParts just like the usual images and I can see them. So, the question is, how do I find an imageId from a Drawing to get those EMF ImageParts? Unfortunately, I can't extract images the other way, because I'm trying to inject my code into a huge existing codebase, so I need to get it from a Drawing object.
Ok, so the problem was that I was looking at a wrong thing.
The Drawing without a Blip that I saw was actually a chart (Insert->Chart), not a PP slide.
Here is the xml for it: http://pastebin.com/9vyBJDLh
There is a chart relation for it pointing to chart1.xml in /charts/ folder.
And there is no EMF generated for the chart.
The slides inserted via "Insert->Object->Microsoft PowerPoint Slide" have completely different format, they are not Drawings and must be handled separately: http://pastebin.com/JJ3piJi3 and rId in imageData element actually points to EMF file under /media/ folder.
I want to convert 2 images into a single pdf file.One image is big in size and small image on the top of the big image.
So In generated pdf also I need to show the small image on the top of the big image and also in the same position where it is in case of image.
I use pdfSharp to convert image to pdf.It will convert the images into pdf file but not able to position the second image on the top of the first image.
Can any one help me on that.Thanks in advance.
Check out the sample below and see if it's what you need:
http://pdfsharp.com/PDFsharp/index.php?option=com_content&task=view&id=34&Itemid=45
I am hoping to make spreadsheets that contain some pictures (embed pictures from files) and I started looking at EPPlus (looks like a great library)
However it seems that the images are not tied to a cell - rather to an x,y, coordinate.
Is there a way with EPPlus or other way to set a cell to a picture (and then manipulate the size of the cell?)
SetPosition
My misunderstanding...
Here is a comment I found when looking around:
No version of Excel allows you to insert a picture into a cell. Pictures are inserted into the worksheet and will always float.
One of the properties of a picture can be set to "move and size with cells" but that only moves or stretches the picture when the underlying rows and columns are inserted, deleted or sized. It does not confine a picture to a cell.
So perhaps I just need to set the properties appropriately.
If I can do this programmatically I will be all set
EDIT
The following code does pretty much what I want/need.
Note that before inserting the pics I set the width and height of the cell I was overlaying to appropriate sizes.
private static void AddImage(ExcelWorksheet ws, int rowIndex, String imageFile)
{
ExcelPicture picture = null;
Bitmap image = new Bitmap(imageFile);
if (image != null)
{
picture = ws.Drawings.AddPicture("pic" + rowIndex.ToString(), image);
picture.From.Column = 0;
picture.From.Row = rowIndex-1;
picture.SetSize(320, 240);
}
}
You can insert the picture, then adjust its .Top and .Left so it aligns with the .Top and .Left of the appropriate cell. You can set the .RowHeight of the cell's row using the same units as the .height of the picture (though there's a maximum height). The .ColumnWidth of the column is in units of text characters wide, so what I do is something like:
myColumn.ColumnWidth = myColumn.ColumnWidth / myColumn.Width * myPicture.Width
and I run it twice because sometimes the first time you set .ColumnWidth, it isn't set precisely.
I don't think you can do that in Excel itself; when you add a picture to an Excel worksheet, it's a floating object, it's not fixed to a specific cell.
Found in the EPPLUS documentation it should be possible with the EditAs setting on value TwoCell.
picture.EditAs = eEditAs.TwoCell;
"Specifies that the current drawing shall move and resize to maintain its row and column anchors (i.e. the object is anchored to the actual from and to row and column). "