尧图网站建设 尧图网络
  • 首页
  • 关于我们
  • 服务项目
  • 案例展示
  • 建站流程
  • 资讯中心
  • 联系我们
首页/资讯中心/详情

CSharp: itextsharp5 imge converter pdf

CSharp:  itextsharp5 imge converter  pdf
📅 发布时间:2026/6/20 11:22:11

 

using iTextSharp.text;
using iTextSharp.text.pdf;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using static System.Net.Mime.MediaTypeNames;namespace HighCharts
{/// <summary>/// geovindu, Geovin Du,塗聚文,涂聚文/// </summary>public partial class itextimagecovertpdf : System.Web.UI.Page{/// <summary>/// /// </summary>/// <param name="sender"></param>/// <param name="e"></param>protected void Page_Load(object sender, EventArgs e){if (!IsPostBack){// Create a new PDF documentDocument doc = new Document(PageSize.A4);string outputPath = Server.MapPath("geovindu.pdf");// Initialize PdfWriterPdfWriter.GetInstance(doc, new FileStream(outputPath, FileMode.Create));// Open the documentdoc.Open();try{// Add a paragraph// doc.Add(new Paragraph("Adding an image to PDF using iTextSharp"));// Load the imagestring imagePath = Server.MapPath("~/AH9_1.png"); // Replace with your image pathiTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(imagePath);// 获取图片尺寸float width = img.Width;float height = img.Height;// Set image propertiesimg.ScaleToFit(width, height); // Resize the imageimg.SetAbsolutePosition(0f, 0f); // Set position (x, y)img.Alignment = Element.ALIGN_CENTER; // Align the image// Add the image to the documentdoc.Add(img);}catch (Exception ex){Response.Write("Error: " + ex.Message);}finally{// Close the documentdoc.Close();}Response.Write("PDF created successfully at " + outputPath);Response.Redirect("output.pdf");}}}
}

  

哲学管理(学)人生, 文学艺术生活, 自动(计算机学)物理(学)工作, 生物(学)化学逆境, 历史(学)测绘(学)时间, 经济(学)数学金钱(理财), 心理(学)医学情绪, 诗词美容情感, 美学建筑(学)家园, 解构建构(分析)整合学习, 智商情商(IQ、EQ)运筹(学)生存.---Geovin Du(涂聚文)

相关新闻

  • 20251011 总结
  • 上课讲的部分 qoj 题记录
  • var与let

最新新闻

  • 合肥理工学校 2026 招生什么条件?2026年6月21号最新公布! - 教育为先
  • 开发K8s准入控制器前的准备工作:集群检查与项目搭建指南
  • 做税务体检怕踩坑?广州中小企业服务筛选全攻略 - 资讯速览
  • STM32F103C8 + FreeRTOS + ESP32 学习记录(一):从零搭建联网天气时钟站(硬件篇)
  • 靠谱营业性演出许可证代办机构推荐 - 资讯速览
  • 想找好用的长沙全屋定制公司?这里给你揭晓答案! - 资讯速览

日新闻

  • 信任的进化:技术实现详解——如何用JavaScript构建博弈论模拟器
  • Terrakube自定义工作流:如何集成OPA、Infracost等工具扩展IaC能力
  • grunt-concurrent快速入门:5分钟学会并行运行Grunt任务

周新闻

  • 3步解锁iOS设备:applera1n激活锁绕过完全指南
  • 39 2026 人工智能证书终极盘点,普通人选 AI 证书可以从这些方向入手
  • Redis 暴露公网有多危险?从端口检查到补救步骤

月新闻

  • 【总结】入门篇:50句话让你记住架构核心概念
  • WeChatMsg技术方案解析:实现Mac微信数据自主管理的完整解决方案
  • WeChatMsg:革新性微信数据备份方案,打造你的专属数字记忆库

关于尧图

  • 公司简介
  • 团队介绍
  • 企业文化
  • 荣誉资质

服务项目

  • 定制开发
  • 电商建站
  • UI 设计
  • 运维服务

快速链接

  • 案例展示
  • 建站流程
  • 常见问题
  • 资讯中心

联系方式

  • 📍北京市朝阳区互联网产业园 A 座 10 层
  • 📞400-888-8888
  • ✉️contact@rkmt.cn
  • 🕐周一至周日 9:00-21:00

© 2024 北京尧图网络科技有限公司 版权所有 | 京 ICP 备 XXXXXXXX 号